-
Hi,
Is there a way to code all the integers in a control array rather than: Val(Text3(0).Text) + Val(Text3(1).Text)+
Val(Text3(2).Text) + Val(Text3(3).Text) + Val(Text3(4).Text) + Val(Text3(5).Text)....etc?
For example:
Private Sub Text5_KeyPress(keyascii As Integer)
keyascii = Asc(Chr(keyascii))
If Val(Text5.Text) = Val(Text3(0).Text) + Val(Text3(1).Text) + Val(Text3(2).Text) + Val(Text3(3).Text) + Val(Text3(4).Text) + Val(Text3(5).Text And keyascii = vbKeyReturn Then
Textcorrect.Text = "Correct!"
End If
End Sub
Thanks for any help!
-
you could loop through them...
Code:
Private Sub Text5_KeyPress(keyascii As Integer)
Dim i As Integer
Dim total As Integer
For i = 0 To Text3.UBound
total = total + Val(Text3(i).Text)
Next
If (Val(Text5.Text) = total) And (keyascii = vbKeyReturn) Then
Textcorrect.Text = "Correct!"
End If
End Sub