How to Define size of variable string during runtime

Reply

Join Date: May 2007
Posts: 537
Reputation: choudhuryshouvi is an unknown quantity at this point 
Solved Threads: 49
choudhuryshouvi's Avatar
choudhuryshouvi choudhuryshouvi is offline Offline
Posting Pro

How to Define size of variable string during runtime

 
0
  #1
Aug 31st, 2007
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........
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: How to Define size of variable string during runtime

 
0
  #2
Sep 2nd, 2007
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
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 537
Reputation: choudhuryshouvi is an unknown quantity at this point 
Solved Threads: 49
choudhuryshouvi's Avatar
choudhuryshouvi choudhuryshouvi is offline Offline
Posting Pro

Re: How to Define size of variable string during runtime

 
0
  #3
Sep 3rd, 2007
could u plz explain what do u meant by "use a collection"? if possible refer to some links.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC