Results 1 to 6 of 6

Thread: how can i dinamically declare variables?

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2000
    Posts
    12

    Question

    i want to declare some variables in my program, but i dont know how many to declare, this is why i need to declare them dinamically.including declaring a different name for them.
    how do i do this?

  2. #2
    Hyperactive Member razzaj's Avatar
    Join Date
    Oct 1999
    Location
    jounieh
    Posts
    261
    As a start you can just declare a "dynamic" array in VB like that :

    dim DynArray() as string


    and each time you want to add an element to that array , you do it this way :

    Redim Preserve DynArray (x)
    DynArray(x-1) = "Hello" & x

    as for declaring variables with new names at runtime ...
    I dont know if it is doable in VB ... Not directly anyway ... I rather not say something of which I am not sure ...
    Hope that helped
    - regards -
    - razzaj -

  3. #3
    Hyperactive Member
    Join Date
    Jul 2000
    Location
    Halifax,UK
    Posts
    274
    can you not use a dynamic array?

    Regards

    Chris.
    VB6 VS2005

  4. #4
    Hyperactive Member razzaj's Avatar
    Join Date
    Oct 1999
    Location
    jounieh
    Posts
    261
    Yes .. depends on your purpose .. but in this case why wouldnt you want to use a dynamic array????
    - regards -
    - razzaj -

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2000
    Posts
    12

    Question my biggest problem is naming the variables

    my biggest problem is naming the variables

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    That shouldn't be a problem, unless they appear to be reserved keywords and functions. You could use prefixes like a, or ad for array or array dynamic, or so, but i wouldn't. Name your variables after their purpose.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width