View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
papou[_11_] papou[_11_] is offline
external usenet poster
 
Posts: 7
Default Excel VBA - TextBox Error

Hi
You may use the IsNumeric function together with the AfterUpdate event of
your textbox:
Private Sub TextBox1_AfterUpdate()
If TextBox1 < "" And Not IsNumeric(TextBox1) Then
MsgBox "Number expected here!" & vbLf & "please try again"
TextBox1.Text = ""
End If
End Sub

HTH
Cordially
Pascal

"bforster1" a écrit dans le message
de ...

I have a created a financial model which includes TextBoxes for the user
to input certain assumptions. If the user does not input a number in
TextBoxes, which are inserted in the spreadsheet, the program creates a
error. For example, if the user enters ".50" it works fine but if the
user enters "..50" by accident it causes a debug error. How can i
protect from this happening?

Thanks


--
bforster1
------------------------------------------------------------------------
bforster1's Profile:

http://www.excelforum.com/member.php...o&userid=11771
View this thread: http://www.excelforum.com/showthread...hreadid=274486