|
-
Feb 8th, 2002, 10:44 AM
#1
Thread Starter
Member
validation in array
how would i code some kind of validation into this peice of code so it only accepts numbers?? maybe case statements// help
Private Sub Command2_Click()
For this = 1 To 18
num = InputBox("Please enter your scores")
nos(this) = num
If nos(this) < 1 Then
MsgBox "Error please enter a valid number > 0"
this = this - 1
End If
Next this
For Counter = 1 To 18
Text1 = Text1 & " | " & nos(Counter)
Next Counter
End Sub
is there any way to take an array back a loop if the dat entered doesnt meet the required format.
-
Feb 8th, 2002, 10:53 AM
#2
Member
-
Feb 8th, 2002, 11:04 AM
#3
Thread Starter
Member
-
Feb 8th, 2002, 11:55 AM
#4
Bouncy Member
Re: validation in array
try this:
VB Code:
Private Sub Form_Load()
Dim nos(18) As Integer
Dim str As String
Dim i As Integer
For i = 0 To 17
str = ""
Do
Do
str = InputBox("Please enter your scores")
If Not IsNumeric(str) Then MsgBox "Must be numerical!"
Loop Until IsNumeric(str)
If Val(str) < 1 Then
MsgBox "Error please enter a valid number > 0"
End If
Loop Until Val(str) > 0
nos(i) = Val(str)
Next i
For i = 0 To 17
Text1 = Text1 & " | " & nos(i)
Next i
End Sub
Last edited by darre1; Feb 8th, 2002 at 11:59 AM.
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
|