Is there anythign in VB6 that works like a Vector, Arraylist or limtiless Array?
Printable View
Is there anythign in VB6 that works like a Vector, Arraylist or limtiless Array?
yes, define an array without limits first and as you assign values to it use redim statement to increase its limit.
So in theory if I was taking strings of information out of a table I could use redim over and over to increase the capacity by 1 every time I add somethign else? and what is the Syntax for this ReDim?
use something like this
ReDim Preserve strString(i)
where preserve will keep your already assigned values in it and just using redim will erase existing contents
Oh my god I can't beleive this, I'm confusing the For loop with the .Net version. How is it done in VB6?
the syntax for the for loop is
for i
the syntax for the for loop is
for i=0 to 10 step 1
your codes
next
Thaks a lot you're a saviour
qualinwraith, could u rate me
sigh, I'm getting a Can't Assign to array error in this line of Code.
Anyonw Know why? mdlConnection is a module, displayRecord is a public function and inArray is an Array than I just declared.VB Code:
Private Sub displayRecord() Dim inArray(9) As String inArray = mdlConnection.displayRecord 'Can't Assign to Array
You can't assign a string to an array. You can assign a string to an array element, which is a string.
What is mdlConnection.displayRecord returning?
An array of strings
OK well in that case you need to make the array dynamic in length so that it can handle the return result properly.
VB Code:
Dim inArray() As String inArray = mdlConnection.displayRecord()
Ah ok then thanks a lot
Is there a way how to break out of a loop?
No but if you find yourself needing to use something like "break;" I suggest a re-think. Maybe a Do loop with an extra continuation condition or something similar.
Or, (horror of horrors) you could use a Goto.
you can use exit do in do loop and exit for in for loop
Hmm, I've been outwitted. I was thinking of "continue" :)
ok...
Thanks a lot guys