• Congratulations to the Class of 2024 on your results!
    Let us know how you went here
    Got a question about your uni preferences? Ask us here

Visual Basic qustion (1 Viewer)

G

Gavvvvvin

Guest
Okay so in my prgram the user has to enter a number which is to be used in a calculation. How do I make the program check whether or not a number has been entered instead of say text?
 

sasquatch

Member
Joined
Aug 15, 2005
Messages
384
Gender
Male
HSC
2006
Gavvvvvin said:
Okay so in my prgram the user has to enter a number which is to be used in a calculation. How do I make the program check whether or not a number has been entered instead of say text?
Simple. Use the inbuilt function "IsNumeric"

e.g.
Code:
If IsNumeric(Text1) = True Then
Msgbox Text1 + 1
Else If
Msgbox "Please enter a number."
End If
 
G

Gavvvvvin

Guest
Grrr my program still crashes when the user doesnt enter a number. Am I supposed to have my user entered variable as a string at first, check it, then convert it to a double after?
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top