|
-
Feb 2nd, 2001, 08:10 PM
#1
Thread Starter
New Member
I am new to vb, obviously. I have a book and typed in an example, which appears below. You don't have to read it all, but this is all the book gave me. What I don't understand is that I typed it into a new modulw (not attached to a form) because I thought that the message box function would bring up a messagebox. Why does nothing come up when I run it? What code should I add, or should I enclose this in a subroutine, and call it? I tried to call it, but I get errors. A stupid question, but I just don't understand.
Thanks for any help
[email protected]
Dim STRAGE As String
Dim intage As Integer
Dim intpress As Integer
' Get the age in a string variable
STRAGE = InputBox("How old are you?", "age Ask")
' Check for the cancel command button
If (STRAGE = "") Then
End 'Terminates the application
End If
' Cancel was not pressed, so convert Age to integer
' The Val() function converts strings to integers
intage = Val(STRAGE)
'Loop if the age is not in the correct range
Do While ((intage < 10) Or (intage > 99))
' The user's age is out of range
intpress = MsgBox("Your Age must be between " & _
"10 and 99", vbExclamation, "error!")
STRAGE = InputBox("How old are you?", "Age Ask")
' Check for the Cancel command button
If (STRAGE = "") Then
End 'Treminate the program
End If
intage = Val(STRAGE)
Loop
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
|