Format


Posted by Landragoran on July 13, 2001 2:28 PM

On a userform, how do I set a textbox to allow only numbers 4 digits long with a format: $1,000 ?

Then how do I set it to allow only text?

Thanks,
landragoran



Posted by Ivan F Moala on July 14, 2001 3:56 AM

Try this.....

'Allow only 4 didgits and formated as $

Private Sub TextBox1_Change()
Dim curpos As Double
Dim x As Integer

curpos = TextBox1.SelStart
If curpos > 5 Then TextBox1.Text = Left(TextBox1.Text, 6)
If Not IsNumeric(TextBox1.Text) Then
On Error Resume Next
TextBox1.Text = Left(TextBox1.Text, curpos - 2)
If Err.Number = 5 Then TextBox1.Text = ""
Err.Clear
End If

TextBox1.Text = Format(TextBox1.Text, "$#,###")

End Sub