Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Numeric or null value
Hi all,
I use the following function to evaluate the contents of a text box on my userform. i want the code to allow either Numbic OR Null values. If the value in the textbox is text, i want the system to fire a message stating the field does not except text values. Problem: This code does not allow the user to tab past an empty cell. Instead, if the user doesn't provide a value, the message fires. Can anyone assist with this one? Function: Public Function EvaluateText(anyEntry As String) _ As Boolean EvaluateText = False ' all is well If Not IsNumeric(anyEntry) Then MsgBox "This field accepts numeric data only. Please revise your entry and try again." EvaluateText = True ' to be copied to Cancel Exit Function ' exit with True End If End Function On Exit Event of Textbox: Private Sub txtPLSFlow_Exit(ByVal Cancel As MSForms.ReturnBoolean) Cancel = EvaluateText(Me!txtPLSFlow.Text) End Sub -- Carlee |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Numeric or null value
Hi Carlee,
Try: Public Function EvaluateText(anyEntry As String) _ As Boolean EvaluateText = False ' all is well If anyEntry="" then Exit Function '<=== added this line to allow null strings. If Not IsNumeric(anyEntry) Then MsgBox "This field accepts numeric data only. Please revise your entry and try again." EvaluateText = True ' to be copied to Cancel Exit Function ' exit with True End If End Function -- Hope that helps. Vergel Adriano "Carlee" wrote: Hi all, I use the following function to evaluate the contents of a text box on my userform. i want the code to allow either Numbic OR Null values. If the value in the textbox is text, i want the system to fire a message stating the field does not except text values. Problem: This code does not allow the user to tab past an empty cell. Instead, if the user doesn't provide a value, the message fires. Can anyone assist with this one? Function: Public Function EvaluateText(anyEntry As String) _ As Boolean EvaluateText = False ' all is well If Not IsNumeric(anyEntry) Then MsgBox "This field accepts numeric data only. Please revise your entry and try again." EvaluateText = True ' to be copied to Cancel Exit Function ' exit with True End If End Function On Exit Event of Textbox: Private Sub txtPLSFlow_Exit(ByVal Cancel As MSForms.ReturnBoolean) Cancel = EvaluateText(Me!txtPLSFlow.Text) End Sub -- Carlee |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Failed to save table attributes of (null) into (null). | Excel Discussion (Misc queries) | |||
Null, "null", vbNull, vbNullString, vbEmpty | Excel Programming | |||
Numeric in Text to convert back to the form of Numeric for VLookup Purposes | Excel Discussion (Misc queries) | |||
Match Single Numeric Criteria and Return Multiple Numeric Labels | Excel Worksheet Functions | |||
How to handle null numeric values in ADO recordset | Excel Programming |