|
-
Nov 15th, 2001, 02:19 PM
#1
Thread Starter
Member
ReDim Array Qusetion "EASY"
I have a series of buttons and an array"array()"
Each button has a corrisponding "Name" associated with it.
When each Button is clicked I need it to add one row to my array and Fill that row with the corrisponding Name, yet keep all previouse names in the array.
I Know this code will cause some kind of out of bound error due to trying to add to an array that is full but I dont know how to get arround it.
Dim array( ) As String
Dim i As Integer
cmdAddSteve_Click( )
i = UBOUND(array( )) + 1
array(i ) = “Steve”
End Sub
cmdAddJohn_Click( )
i = UBOUND(array()) + 1
array(i ) = “John”
End Sub
cmdAddSusan_Click( )
i = UBOUND(array()) + 1
array(i ) = “John”
End Sub
Last edited by Alakazam; Nov 15th, 2001 at 02:55 PM.
-
Nov 15th, 2001, 02:21 PM
#2
Redim Preserve array(i+1)
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Nov 15th, 2001, 02:57 PM
#3
Thread Starter
Member
You mean like this?
Dim IC( ) As String
Dim i As Integer
cmdAddSteve_Click( )
i = UBOUND(IC( )) + 1
Redim Preserve array(i+1)
IC(i ) = “Steve”
End Sub
-
Nov 15th, 2001, 03:18 PM
#4
i = UBOUND(IC( )) + 1
Redim Preserve array(i+1)
IC(i ) = “Steve”
array was just a "fake" name....your array name is IC()
so use IC
do it like this...
I = Ubound(IC) + 1
Redim Preserve IC(i)
IC(i) = "Steve"
ok?
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Nov 15th, 2001, 05:51 PM
#5
Thread Starter
Member
This Does Not Work
Dim IC() As String
Dim i As Integer, ii As Integer
Private Sub Command1_Click(Index As Integer)
i = UBound(IC) + 1 'Subscript out of range
ReDim Preserve IC(i)
IC(i) = "Steve"
End Sub
Private Sub Command2_Click()
i = UBound(IC) + 1
ReDim Preserve IC(i)
IC(i) = "Jane"
End Sub
Private Sub Command3_Click()
'Check to see values of IC() array
For ii = 0 To UBound(IC)
Print IC(ii)
Next ii
End Sub
-
Nov 15th, 2001, 05:56 PM
#6
Need-a-life Member
Try adding this code:
VB Code:
Private Sub Form_Load()
ReDim IC(0)
End Sub
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
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
|