Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Textbox Data IsNumeric

I guess we all know that IsNumeric does not work 100% of the time when used
with Userform Textboxes. This is the format that I am looking for from the
users #####-# or ADT##-#. How can I ensure I have this format? This is what
I have so far:


' must have correct Item # to apply to schedule
If Len(tbxItemNumber) < 7 Then
strPrompt = "You must have a correct Item # to continue. It must be
" & _
"in this format: ''#####-#''"
intButtons = vbCritical
MsgBox strPrompt, intButtons, strTitle
DataValidator = True
Exit Function
End If

--
Cheers,
Ryan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 471
Default Textbox Data IsNumeric

If Len(tbxItemNumber) < 7 Then
'code you have
elseif left(tbxItemNumber,3)<"ADT" then
strPrompt ="Must start with ADT, etc...."
elseif mid(tbxItemNumber,6,1)<"-" then
strPrompt ="Must have a dash in position 6!"
end if


"RyanH" wrote:

I guess we all know that IsNumeric does not work 100% of the time when used
with Userform Textboxes. This is the format that I am looking for from the
users #####-# or ADT##-#. How can I ensure I have this format? This is what
I have so far:


' must have correct Item # to apply to schedule
If Len(tbxItemNumber) < 7 Then
strPrompt = "You must have a correct Item # to continue. It must be
" & _
"in this format: ''#####-#''"
intButtons = vbCritical
MsgBox strPrompt, intButtons, strTitle
DataValidator = True
Exit Function
End If

--
Cheers,
Ryan

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Textbox Data IsNumeric

Give this a try...

' must have correct Item # to apply to schedule
If Len(tbxItemNumber) < 7 Or _
Not tbxItemNumber Like "[0-9Aa][0-9Dd][0-9Tt]##-##" Then
strPrompt = "You must have a correct Item # to continue. " & _
"It must be in this format: ''#####-#''"
intButtons = vbCritical
MsgBox strPrompt, intButtons, strTitle
DataValidator = True
Exit Function
End If

--
Rick (MVP - Excel)


"RyanH" wrote in message
...
I guess we all know that IsNumeric does not work 100% of the time when used
with Userform Textboxes. This is the format that I am looking for from
the
users #####-# or ADT##-#. How can I ensure I have this format? This is
what
I have so far:


' must have correct Item # to apply to schedule
If Len(tbxItemNumber) < 7 Then
strPrompt = "You must have a correct Item # to continue. It must
be
" & _
"in this format: ''#####-#''"
intButtons = vbCritical
MsgBox strPrompt, intButtons, strTitle
DataValidator = True
Exit Function
End If

--
Cheers,
Ryan


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Textbox Data IsNumeric

I tried entering the following: 11111-1, ADT12-1 and I am getting the
MsgBox. Did I do something wrong?

' must have correct Item # to apply to schedule
If Len(tbxItemNumber) < 7 Or Not tbxItemNumber Like
"[0-9A][0-9D][0-9T]##-##" Then
strPrompt = "You must have a correct Item # to continue. It must be
" & _
"in this format: ''#####-#''"
intButtons = vbCritical
MsgBox strPrompt, intButtons, strTitle
DataValidator = True
Exit Function
End If
--
Cheers,
Ryan


"Rick Rothstein" wrote:

Give this a try...

' must have correct Item # to apply to schedule
If Len(tbxItemNumber) < 7 Or _
Not tbxItemNumber Like "[0-9Aa][0-9Dd][0-9Tt]##-##" Then
strPrompt = "You must have a correct Item # to continue. " & _
"It must be in this format: ''#####-#''"
intButtons = vbCritical
MsgBox strPrompt, intButtons, strTitle
DataValidator = True
Exit Function
End If

--
Rick (MVP - Excel)


"RyanH" wrote in message
...
I guess we all know that IsNumeric does not work 100% of the time when used
with Userform Textboxes. This is the format that I am looking for from
the
users #####-# or ADT##-#. How can I ensure I have this format? This is
what
I have so far:


' must have correct Item # to apply to schedule
If Len(tbxItemNumber) < 7 Then
strPrompt = "You must have a correct Item # to continue. It must
be
" & _
"in this format: ''#####-#''"
intButtons = vbCritical
MsgBox strPrompt, intButtons, strTitle
DataValidator = True
Exit Function
End If

--
Cheers,
Ryan



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Textbox Data IsNumeric

No, you didn't do anything wrong... I did. I added an extra digit
requirement after the dash by mistake. Try this instead...

' must have correct Item # to apply to schedule
If Len(tbxItemNumber) < 7 Or _
Not tbxItemNumber Like "[0-9Aa][0-9Dd][0-9Tt]##-#" Then
strPrompt = "You must have a correct Item # to continue. " & _
"It must be in this format: ''#####-#''"
intButtons = vbCritical
MsgBox strPrompt, intButtons, strTitle
DataValidator = True
Exit Function
End If


--
Rick (MVP - Excel)


"RyanH" wrote in message
...
I tried entering the following: 11111-1, ADT12-1 and I am getting the
MsgBox. Did I do something wrong?

' must have correct Item # to apply to schedule
If Len(tbxItemNumber) < 7 Or Not tbxItemNumber Like
"[0-9A][0-9D][0-9T]##-##" Then
strPrompt = "You must have a correct Item # to continue. It must
be
" & _
"in this format: ''#####-#''"
intButtons = vbCritical
MsgBox strPrompt, intButtons, strTitle
DataValidator = True
Exit Function
End If
--
Cheers,
Ryan


"Rick Rothstein" wrote:

Give this a try...

' must have correct Item # to apply to schedule
If Len(tbxItemNumber) < 7 Or _
Not tbxItemNumber Like "[0-9Aa][0-9Dd][0-9Tt]##-##" Then
strPrompt = "You must have a correct Item # to continue. " & _
"It must be in this format: ''#####-#''"
intButtons = vbCritical
MsgBox strPrompt, intButtons, strTitle
DataValidator = True
Exit Function
End If

--
Rick (MVP - Excel)


"RyanH" wrote in message
...
I guess we all know that IsNumeric does not work 100% of the time when
used
with Userform Textboxes. This is the format that I am looking for from
the
users #####-# or ADT##-#. How can I ensure I have this format? This
is
what
I have so far:


' must have correct Item # to apply to schedule
If Len(tbxItemNumber) < 7 Then
strPrompt = "You must have a correct Item # to continue. It
must
be
" & _
"in this format: ''#####-#''"
intButtons = vbCritical
MsgBox strPrompt, intButtons, strTitle
DataValidator = True
Exit Function
End If

--
Cheers,
Ryan






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Textbox Data IsNumeric

I should have seen that myself. It works great! Thanks again.
--
Cheers,
Ryan


"Rick Rothstein" wrote:

No, you didn't do anything wrong... I did. I added an extra digit
requirement after the dash by mistake. Try this instead...

' must have correct Item # to apply to schedule
If Len(tbxItemNumber) < 7 Or _
Not tbxItemNumber Like "[0-9Aa][0-9Dd][0-9Tt]##-#" Then
strPrompt = "You must have a correct Item # to continue. " & _
"It must be in this format: ''#####-#''"
intButtons = vbCritical
MsgBox strPrompt, intButtons, strTitle
DataValidator = True
Exit Function
End If


--
Rick (MVP - Excel)


"RyanH" wrote in message
...
I tried entering the following: 11111-1, ADT12-1 and I am getting the
MsgBox. Did I do something wrong?

' must have correct Item # to apply to schedule
If Len(tbxItemNumber) < 7 Or Not tbxItemNumber Like
"[0-9A][0-9D][0-9T]##-##" Then
strPrompt = "You must have a correct Item # to continue. It must
be
" & _
"in this format: ''#####-#''"
intButtons = vbCritical
MsgBox strPrompt, intButtons, strTitle
DataValidator = True
Exit Function
End If
--
Cheers,
Ryan


"Rick Rothstein" wrote:

Give this a try...

' must have correct Item # to apply to schedule
If Len(tbxItemNumber) < 7 Or _
Not tbxItemNumber Like "[0-9Aa][0-9Dd][0-9Tt]##-##" Then
strPrompt = "You must have a correct Item # to continue. " & _
"It must be in this format: ''#####-#''"
intButtons = vbCritical
MsgBox strPrompt, intButtons, strTitle
DataValidator = True
Exit Function
End If

--
Rick (MVP - Excel)


"RyanH" wrote in message
...
I guess we all know that IsNumeric does not work 100% of the time when
used
with Userform Textboxes. This is the format that I am looking for from
the
users #####-# or ADT##-#. How can I ensure I have this format? This
is
what
I have so far:


' must have correct Item # to apply to schedule
If Len(tbxItemNumber) < 7 Then
strPrompt = "You must have a correct Item # to continue. It
must
be
" & _
"in this format: ''#####-#''"
intButtons = vbCritical
MsgBox strPrompt, intButtons, strTitle
DataValidator = True
Exit Function
End If

--
Cheers,
Ryan




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
Copy Textbox data to Textbox in Other File Troubled User Excel Programming 2 October 6th 08 06:42 PM
isnumeric() and hyphen John Smith Excel Programming 5 November 22nd 06 11:02 PM
Isnumeric Richard Excel Programming 3 February 26th 06 08:20 PM
opposite of IsNumeric thephoenix12[_3_] Excel Programming 2 June 23rd 05 10:29 PM
Not IsNumeric not working - or is it me? Ed Excel Programming 3 January 6th 05 11:30 PM


All times are GMT +1. The time now is 12:45 AM.

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"