Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
User Form Controls
"Ben E" wrote in message ... Hi all, Is it possible within a excel user form to set a text box to: 1) only accept numbers 2) only accept a set number of characters Ie the user can only input a 4 number code. Ben E The best option is probably to use the textbox change event the example below will only permit numbers to be entered Private Sub TextBox1_Change() Dim keyascii As Integer If TextBox1.Text < "" Then keyascii = Asc(Right(TextBox1.Text, 1)) If keyascii 47 And keyascii < 58 Then ' If its a number allow it Else ' Else throw away the change TextBox1.Text = Mid(TextBox1.Text, 1, Len(TextBox1.Text) - 1) End If End If End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
ActiveX Controls vs Form Controls | Excel Discussion (Misc queries) | |||
User Form Controls | Excel Programming | |||
User Form Controls | Excel Programming | |||
User Form Controls | Excel Programming | |||
user form controls | Excel Programming |