VBA_Userform_TextBox only number

icey67

New Member
Joined
Aug 12, 2002
Messages
10
Do you know how to set properties of textbox,
so it could only accepting numbers instead of text ?
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
WELCOME TO THE BOARD!

I am sure there a several ways to do it. If you have a TextBox and a CommandButton, you could do this:

Sub CommandButton_Click()

If IsNumeric(TextBox1.Value) Then
Exit Sub
End If
MsgBox "Invalid entry. Numbers are only allowed."
TextBox1.Select
Selection.ClearContents
End Sub

Did this help out?
 
Upvote 0
On 2002-08-14 01:39, icey67 wrote:
Do you know how to set properties of textbox,
so it could only accepting numbers instead of text ?

Hi icey67
The textbox unfortunatly doesn't have a masking property so you will have to resort to doing this yourself eg. as Phantom has given....there are nemuerous ways to do this.
What is your criteria ??
ie. Whole numbers, Real numbers, any limits to the length of the numbers ie. number of didgits??
 
Upvote 0
What I want is that user get a pop-up message/warning after typing an input containing non numeric value.
 
Upvote 0

Forum statistics

Threads
1,214,648
Messages
6,120,726
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top