|
-
Jan 24th, 2006, 05:04 AM
#1
Thread Starter
Member
Vectors and Arraylists
Is there anythign in VB6 that works like a Vector, Arraylist or limtiless Array?
-
Jan 24th, 2006, 05:10 AM
#2
Re: Vectors and Arraylists
yes, define an array without limits first and as you assign values to it use redim statement to increase its limit.
-
Jan 24th, 2006, 05:16 AM
#3
Thread Starter
Member
Re: Vectors and Arraylists
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?
-
Jan 24th, 2006, 05:22 AM
#4
Re: Vectors and Arraylists
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
-
Jan 24th, 2006, 05:36 AM
#5
Thread Starter
Member
Re: Vectors and Arraylists
Oh my god I can't beleive this, I'm confusing the For loop with the .Net version. How is it done in VB6?
-
Jan 24th, 2006, 05:39 AM
#6
Re: Vectors and Arraylists
the syntax for the for loop is
for i
-
Jan 24th, 2006, 05:39 AM
#7
Re: Vectors and Arraylists
the syntax for the for loop is
for i=0 to 10 step 1
your codes
next
-
Jan 24th, 2006, 05:51 AM
#8
Thread Starter
Member
Re: Vectors and Arraylists
Thaks a lot you're a saviour
-
Jan 24th, 2006, 06:05 AM
#9
Re: Vectors and Arraylists
qualinwraith, could u rate me
-
Jan 24th, 2006, 06:46 AM
#10
Thread Starter
Member
Re: Vectors and Arraylists
sigh, I'm getting a Can't Assign to array error in this line of Code.
VB Code:
Private Sub displayRecord()
Dim inArray(9) As String
inArray = mdlConnection.displayRecord 'Can't Assign to Array
Anyonw Know why? mdlConnection is a module, displayRecord is a public function and inArray is an Array than I just declared.
-
Jan 24th, 2006, 06:49 AM
#11
Re: Vectors and Arraylists
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?
-
Jan 24th, 2006, 06:57 AM
#12
Thread Starter
Member
Re: Vectors and Arraylists
-
Jan 24th, 2006, 07:00 AM
#13
Re: Vectors and Arraylists
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()
-
Jan 24th, 2006, 07:01 AM
#14
Thread Starter
Member
Re: Vectors and Arraylists
-
Jan 24th, 2006, 07:06 AM
#15
Thread Starter
Member
Re: Vectors and Arraylists
Is there a way how to break out of a loop?
-
Jan 24th, 2006, 07:08 AM
#16
Re: Vectors and Arraylists
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.
-
Jan 24th, 2006, 07:11 AM
#17
Re: Vectors and Arraylists
you can use exit do in do loop and exit for in for loop
-
Jan 24th, 2006, 07:13 AM
#18
Re: Vectors and Arraylists
Hmm, I've been outwitted. I was thinking of "continue"
-
Jan 24th, 2006, 07:14 AM
#19
Re: Vectors and Arraylists
-
Jan 24th, 2006, 07:54 AM
#20
Thread Starter
Member
Re: Vectors and Arraylists
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|