Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default Test for string of space chars?

I have a textbox on my main Userform that allows
someone type type in text. I would like to be able
to test for cases when "nothing" is entered into
the textbox, meaning no keystrokes were pressed
inside the textbox. Additionally, I would like to know
if the user pressed a sequence of blank or space characters.

For example, if someone presses the spacebar a couple
times, or the tab key, or a mixture of both, I would like
some function to tell me that the text string contains a
set of whitespace or blank characters.

Or would it just be easier to test if the string contains
ALL alphanumeric characters?

Thanks!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 236
Default Test for string of space chars?

Chekc out Len(Trim(userform.txtbxFName.text))
e.g.,
If Len(Trim(userform.txtbxFName.text))=0 then
MsgBox "Nope, you have to enter something for the First name"
End if


On Dec 30, 10:42*am, "Robert Crandal" wrote:
I have a textbox on my main Userform that allows
someone type type in text. *I would like to be able
to test for cases when "nothing" is entered into
the textbox, meaning no keystrokes were pressed
inside the textbox. *Additionally, I would like to know
if the user pressed a sequence of blank or space characters.

For example, if someone presses the spacebar a couple
times, or the tab key, or a mixture of both, I would like
some function to tell me that the text string contains a
set of whitespace or blank characters.

Or would it just be easier to test if the string contains
ALL alphanumeric characters?

Thanks!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Test for string of space chars?

Using Trim may remove the space(s) he wants to detect. I would just do
something like this:

If txtWhatever.Value="" then

No need to specify the userform name if the code is in the userform module.

"AB" wrote in message
...
Chekc out Len(Trim(userform.txtbxFName.text))
e.g.,
If Len(Trim(userform.txtbxFName.text))=0 then
MsgBox "Nope, you have to enter something for the First name"
End if

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 236
Default Test for string of space chars?

I could be wrong, but perhaps Robert wants to validate text boxes -
that users enter something but blanks in there - hence trim actually
helps.
In the other post Rob had a code referencing the userform externally,
hence used the form reference too.

On Dec 30, 11:39*am, "Jim Rech" wrote:
Using Trim may remove the space(s) he wants to detect. *I would just do
something like this:

*If txtWhatever.Value="" then

No need to specify the userform name if the code is in the userform module.

"AB" wrote in message

...
Chekc out Len(Trim(userform.txtbxFName.text))
e.g.,
If Len(Trim(userform.txtbxFName.text))=0 then
* MsgBox "Nope, you have to enter something for the First name"
End if


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default Test for string of space chars?

Thanks.....that works for me.

"AB" wrote in message
...
Chekc out Len(Trim(userform.txtbxFName.text))
e.g.,
If Len(Trim(userform.txtbxFName.text))=0 then
MsgBox "Nope, you have to enter something for the First name"
End if



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
Mind-numbing simple data validation ... string from 1 to 64 chars Will Finkle Excel Worksheet Functions 6 September 16th 07 03:10 PM
macro to bold number of chars from end of a string herbwarri0r Excel Discussion (Misc queries) 4 June 6th 06 01:21 PM
extracting a single char from a string of chars Alan Excel Programming 2 August 17th 05 02:55 PM
remove blanks from a string of chars within a cell? rayhollidge Excel Discussion (Misc queries) 3 January 8th 05 02:43 AM
Counting chars in a string bcmiller[_4_] Excel Programming 2 May 21st 04 11:00 AM


All times are GMT +1. The time now is 06:18 AM.

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

About Us

"It's about Microsoft Excel"