|
-
Mar 10th, 2000, 02:51 AM
#1
Thread Starter
Hyperactive Member
I know the basics about adding numbers in text boxes. For instance:
Private Sub text4_KeyPress(keyascii As Integer)
keyascii = Asc(Chr(keyascii))
If Val(Text4.Text) = Val(Text1.Text) + Val(Text2.Text) And keyascii = vbKeyReturn Then
Text3.Visible = True
End If
End Sub
But the text box with the numbers that are added is a control array - and the number of text boxes in the array can vary (they can be created at run time).
How can I add the numbers in the text boxes if the text box is an array? I thought something like below would do it, but it doesn't:
Private Sub text4_KeyPress(keyascii As Integer)
Dim index As Integer
For index = 1 To Text1.UBound - 1
keyascii = Asc(Chr(keyascii))
If Val(Text4.Text) = Val(Text1.UBound) And keyascii = vbKeyReturn Then
Text3.Visible = True
End If
Next index
End Sub
Any help would be much appreciated!
Slan
-
Mar 10th, 2000, 03:25 AM
#2
Hyperactive Member
Code:
i = 0
Do While IsObject(Text1(i))
Text1(i).Text = "1"
i = i + 1
Loop
Edited by Phobic on 03-10-2000 at 03:26 PM
-
Mar 11th, 2000, 03:35 AM
#3
Thread Starter
Hyperactive Member
Phobic, I tried your code but it didn't work:
Private Sub text4_KeyPress(keyascii As Integer)
keyascii = Asc(Chr(keyascii))
i = 0
If Val(Text4.Text) = Val(Text2(i).Text) And keyascii = vbKeyReturn Then
Picture4.Visible = True
Picture5.Visible = False
Do While IsObject(Text2(i))
Text2(i).Text = "1"
i = i + 1
Loop
End If
End Sub
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
|