Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 155
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Failed to save table attributes of (null) into (null). Luca Brasi Excel Discussion (Misc queries) 2 February 4th 09 04:30 PM
Null, "null", vbNull, vbNullString, vbEmpty [email protected] Excel Programming 2 July 25th 06 01:28 PM
Numeric in Text to convert back to the form of Numeric for VLookup Purposes achilles Excel Discussion (Misc queries) 4 February 6th 06 07:05 AM
Match Single Numeric Criteria and Return Multiple Numeric Labels Sam via OfficeKB.com Excel Worksheet Functions 0 December 29th 05 08:44 PM
How to handle null numeric values in ADO recordset FlaviusFlav Excel Programming 11 May 20th 04 09:44 PM


All times are GMT +1. The time now is 05:56 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"