Board index » Visual Studio » Checking Strings
|
vbakraker
|
|
vbakraker
|
Checking Strings
Visual Studio94
Im having one of those brain dead days today, I carnt remember how to check a string to ensure that it only contains the letters in the range a-z and nothing else - |
| Ilya
Registered User |
Thu Jan 15 07:33:27 CST 2004
Re:Checking Strings
Not "lwkd" Like "*[!a-z]*"
returns true and Not "lwkd3" Like "*[!a-z]*" returns false "Peter Newman" <anonymous@discussions.microsoft.com>wrote in message QuoteIm having one of those brain dead days today, - |
| Peter
Registered User |
Thu Jan 15 08:44:26 CST 2004
Re:Checking Strings
THanks.. though im still struggling with one aspect
When some one enters a Telephone number i use the validate function and use If Not UserData(TelephoneNumber).Text Like "*[!0-9]*" which works fine to check if only the numbers 0 - 9 are present, however once i have formatted the data using Format(number, "0## #### ####") the validate fails Quote-----Original Message----- |
| Rick
Registered User |
Thu Jan 15 09:15:38 CST 2004
Re:Checking StringsQuoteWhen some one enters a Telephone number i use the (the two blank spaces). If you validate the number before you format it, why would you need to check it afterwards? I mean, if it is all digits before you do the Format statement, it will (aside from the blank spaces being added) be all digits afterwards also. Rick - MVP - |
| ChrisM
Registered User |
Thu Jan 15 09:29:31 CST 2004
Re:Checking Strings
Peter,
Don't forget when you apply the formatting to the string you are adding spaces into the it, so that it no longer contains just the characters '0'-'9'. So what you need to do is change your test slightly: formattedNumber = Format(UserData(TelephoneNumber).Text , "0## #### ####") If Not UserData(formattedNumber).Text Like "*[!0-9] *" Note the space character between the ']' and the '*' Cheers, ChrisM "Peter Newman" <anonymous@discussions.microsoft.com>wrote in message QuoteTHanks.. though im still struggling with one aspect - |
| Rick
Registered User |
Thu Jan 15 09:42:30 CST 2004
Re:Checking StringsQuoteDon't forget when you apply the formatting to the string you are adding otherwise, a text string like UserData(formattedNumber).Text = "1x3 4567 8901" will report incorrectly. Of course, the space character can't go in front of the exclamation character or between the 0 and 9. Rick - MVP - |
| ChrisM
Registered User |
Thu Jan 15 10:08:34 CST 2004
Re:Checking Strings
Oops,
Sorry Peter (and thanks Rick) I had it the right way round when I was checking on my PC, then had a brain-storm while writing my post! I think I went to bed too late last night... ChrisM "Rick Rothstein" <rickNOSPAMnews@NOSPAMcomcast.net>wrote in message Quote>Don't forget when you apply the formatting to the string you are adding - |
