Dynamically define variables in VB.Net/ASP.Net

Discussion in 'ASP .Net' started by SV, May 20, 2008.

  1. SV

    SV Guest

    Hi there,

    I am using ASP.Net 2.0 with VB.Net.

    I want to define variables. For example I want to create variable of
    type TableRow and while defining I don't know how many rows i needed.
    So what i want to do in my code:

    For i As Integer = 0 To dt.Tables(0).Rows.Count - 1
    dim tr_i as New TableRow

    ' other code.....

    Next i

    But it will define variable as tr_i...but i want tr_0,
    tr_1,tr_2,.........

    Is it possible?

    Thanks,

    SV
     
    SV, May 20, 2008
    #1
    1. Advertising

  2. It is possible that you are not exactly on the right track. What do you want
    to achieve?

    --
    Eliyahu Goldin,
    Software Developer
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin
    http://usableasp.net


    "SV" <> wrote in message
    news:...
    > Hi there,
    >
    > I am using ASP.Net 2.0 with VB.Net.
    >
    > I want to define variables. For example I want to create variable of
    > type TableRow and while defining I don't know how many rows i needed.
    > So what i want to do in my code:
    >
    > For i As Integer = 0 To dt.Tables(0).Rows.Count - 1
    > dim tr_i as New TableRow
    >
    > ' other code.....
    >
    > Next i
    >
    > But it will define variable as tr_i...but i want tr_0,
    > tr_1,tr_2,.........
    >
    > Is it possible?
    >
    > Thanks,
    >
    > SV
     
    Eliyahu Goldin, May 20, 2008
    #2
    1. Advertising

  3. SV

    SV Guest

    Thanks all for your replies.

    I think I was not able to explain you very well. But I tried to do the
    things using arrays but didn’t get exactly what I want.
    Anyways, I have solved the problem.

    I really appreciate your precious replies.
    Thanks.



    On May 20, 6:28 pm, "Mark Rae [MVP]" <> wrote:
    > "SV" <> wrote in message
    >
    > news:...
    >
    > > Is it possible?

    >
    > As others have mentioned, dynamic variables are possible in .NET but are
    > generally considered to be poor programming practice.
    >
    > There will almost certainly be much more efficient methods - can you explain
    > a bit more about what you're trying to do...?
    >
    > --
    > Mark Rae
    > ASP.NET MVPhttp://www.markrae.net
     
    SV, May 21, 2008
    #3
  4. re:
    !> Anyways, I have solved the problem

    It could help others if you posted the solution you arrived at.
    Sharing information like that is the very purpose of these newsgroups.

    Can you ?



    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ======================================
    "SV" <> wrote in message news:...
    Thanks all for your replies.

    I think I was not able to explain you very well. But I tried to do the
    things using arrays but didn’t get exactly what I want.
    Anyways, I have solved the problem.

    I really appreciate your precious replies.
    Thanks.



    On May 20, 6:28 pm, "Mark Rae [MVP]" <> wrote:
    > "SV" <> wrote in message
    >
    > news:...
    >
    > > Is it possible?

    >
    > As others have mentioned, dynamic variables are possible in .NET but are
    > generally considered to be poor programming practice.
    >
    > There will almost certainly be much more efficient methods - can you explain
    > a bit more about what you're trying to do...?
    >
    > --
    > Mark Rae
    > ASP.NET MVPhttp://www.markrae.net
     
    Juan T. Llibre, May 21, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. C.F.
    Replies:
    1
    Views:
    386
    Shailya
    Apr 14, 2005
  2. theotyflos
    Replies:
    3
    Views:
    496
    Thomas Matthews
    Feb 19, 2004
  3. robin liu
    Replies:
    3
    Views:
    847
    Robin Liu
    Apr 21, 2006
  4. Replies:
    9
    Views:
    997
  5. Brian Takita

    #define _ and #define __

    Brian Takita, Jan 23, 2006, in forum: Ruby
    Replies:
    0
    Views:
    499
    Brian Takita
    Jan 23, 2006
Loading...

Share This Page