-
loop pain again!!!
HELP !:o :D
how to loop back usr input if num > 6 or num= decimal point?
my code:
Public Sub Try()
Dim i As Integer
Dim sResult As String
Dim sStore As String
Dim sFreq(1 To 6) As String
Dim iResponse As Integer
For i = 1 To 6
sFreq(i) = i
Next
Do
sResult = Application.InputBox("Please Input a Frequency", "Frequency Input", _
"Please Input an Integer Value", Type:=1)
For i = 1 To 6
If sResult = sFreq(i) Then
sStore = sResult
ChDir "C:\Workbooks.Open" Filename:="C:\Testing.xls"
Sheets(i).Select
Call CreateChart
Exit Do
End If
Next
iResponse = MsgBox("Invalid input. Please try again.", vbOKOnly)
Loop Until iResponse = i
End Sub
-
How about this?
Do
sResult = InputBox$("Please input a frequency....)
For i = 1 To 6
If CInt( sResult) = sFreq( i ) Then
'Do something here...if equal
Exit For
End If
Next i
If i > 6 Then
Call Msgbox("Invalid Input...)
Else
Exit Do
End If
Loop Until True
-
thanks rbnwares.
i hv get it done.
-
Code:
Dim strInpBox As String
strInpBox = InputBox("Enter A Number ...")
If (StrPtr(strInpBox) = 0) Then
MsgBox "You hit the cancel button"
ElseIf Not (IsNumeric(strInpBox)) Then
MsgBox "You didn't enter a numeric value"
ElseIf (CInt(strInpBox) > 6) Then
MsgBox "The number's above 6"
ElseIf (InStr(strInpBox, ".")) Then
MsgBox "The number has a decimal place in"
Else
MsgBox "Number's fine !"
End If
That should more or less cover everthing the user could do to bugger the number up :D If you need any of that explained, let me know. ;)