944,162 Members | Top Members by Rank

Ad:
Aug 31st, 2007
0

How to Define size of variable string during runtime

Expand Post »
Hi to all, here is my question:-

i've declared an user defined type like this -

public type user
str() as string
end type


where str() is an string array with empty elements. now i want to create the elements dynamically. for that i wrote these -

dim x as integer
dim s as user

x=val(txtfields.text)-1
redim s.str(x)


where x is the variable which contains total no. of elements to be passed to the array. suppose if x contains 5 then the str() will become str(5). the array will populate with 5 elements.

to this point, it's completely ok. now the crutial thing is i also need to define the size of each elements like this - str(0) as string * 5; str(1) as string * 6, etc during runtime. now how can i do that? is there any possibility?

Plz reply on this............soon

Thanks in advance........
Similar Threads
Reputation Points: 30
Solved Threads: 49
Posting Pro
choudhuryshouvi is offline Offline
553 posts
since May 2007
Sep 2nd, 2007
0

Re: How to Define size of variable string during runtime

Hi,

No, u cannot change the Length of each string in that array, U have 2 work arounds :
Use a Collection
Or
Mantain a Seperate Array, which holds Corresponding Lengths of the string Array.. (Both linked with same Index)

REgards
Veena
Reputation Points: 84
Solved Threads: 140
Posting Shark
QVeen72 is offline Offline
923 posts
since Nov 2006
Sep 3rd, 2007
0

Re: How to Define size of variable string during runtime

could u plz explain what do u meant by "use a collection"? if possible refer to some links.
Reputation Points: 30
Solved Threads: 49
Posting Pro
choudhuryshouvi is offline Offline
553 posts
since May 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: sql query error
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: random number generation





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC