dzogchen
04-02-2011, 05:38 AM
Hello,
I have 6 TextBoxes which I want to retrieve values to the "a" Array.
This is the code that I have develop so far:
Private Sub CommandButton1_Click()
Dim box, i As Integer
Dim a As Long
Dim textboxes() As TextBox
box = 0
If TextBox1 <> "" Then box = box + 1
If TextBox2 <> "" Then box = box + 1
If TextBox3 <> "" Then box = box + 1
If TextBox4 <> "" Then box = box + 1
If TextBox5 <> "" Then box = box + 1
If TextBox6 <> "" Then box = box + 1
ReDim a(0 To 6)
For i = 0 To box
a(i) = textboxes(i)
Range("a1").Value = a(i)
Next i
End Sub
The name of this post is Dynamic Array because I would like to ignore empty TextBoxes and create the Array dimension dependent of TextBoxes,
but a(i) = textboxes(i) is not working
Could someone give me a hand please?
Regards
I have 6 TextBoxes which I want to retrieve values to the "a" Array.
This is the code that I have develop so far:
Private Sub CommandButton1_Click()
Dim box, i As Integer
Dim a As Long
Dim textboxes() As TextBox
box = 0
If TextBox1 <> "" Then box = box + 1
If TextBox2 <> "" Then box = box + 1
If TextBox3 <> "" Then box = box + 1
If TextBox4 <> "" Then box = box + 1
If TextBox5 <> "" Then box = box + 1
If TextBox6 <> "" Then box = box + 1
ReDim a(0 To 6)
For i = 0 To box
a(i) = textboxes(i)
Range("a1").Value = a(i)
Next i
End Sub
The name of this post is Dynamic Array because I would like to ignore empty TextBoxes and create the Array dimension dependent of TextBoxes,
but a(i) = textboxes(i) is not working
Could someone give me a hand please?
Regards