Numbers Only in input box

  • Thread starter Thread starter Greg
  • Start date Start date
G

Greg

Hi all,

Just wondering how I can have the following code to check if the answer is
only in numeric form?

dim Checker

checker = inputbox("What is the player's registration number?")


Thanks in advance

Greg
 
Sorry just to add to that if the answer is not right can it be looped back
to the inputbox again

Thanks

Greg
 
The following code will loop until the user enters a number greater than 10.
Note that the code uses Excel's InputBox method, not the standard VBA
InputBox function. The 'Application.' is required.

Dim D As Double
Do Until D > 10
D = Application.InputBox(prompt:="Enter a number.", Type:=1)
Loop


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)
 
you could try the inputbox method (versus inputbox function). it will
restrict the input to numbers, but you still have to check to see if they
canceled the inputbox.

Sub test()
Dim checker As Long

checker = Clng(Application.InputBox("What is the player's registration
number?", Type:=1))
If checker = 0 Then Exit Sub

End Sub
 
Thanks for that Chip will try

Greg
Chip Pearson said:
The following code will loop until the user enters a number greater than
10. Note that the code uses Excel's InputBox method, not the standard VBA
InputBox function. The 'Application.' is required.

Dim D As Double
Do Until D > 10
D = Application.InputBox(prompt:="Enter a number.", Type:=1)
Loop


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top