Group:  Microsoft Word ยป microsoft.public.word.vba.beginners
Thread: If Selection does not contain a Number or Colon

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

If Selection does not contain a Number or Colon
Frankbelly 30.09.2006 03:10:02
I'm trying to determine if the current selection contains any characters that
are not a digit or a colon

Any help is greatly appreciated

Thanks
Re: If Selection does not contain a Number or Colon
"Jean-Guy Marcil" <NoSpam[ at ]LeaveMeAlone> 30.09.2006 04:38:25
Frankbelly was telling us:
Frankbelly nous racontait que :

[Quoted Text]
> I'm trying to determine if the current selection contains any
> characters that are not a digit or a colon
>
> Any help is greatly appreciated

Try something like this:

Sub CheckForDigitColon()

Dim strToCheck As String
Dim i As Long

strToCheck = Selection.Text
i = 1

Do
If Not Mid(strToCheck, i, 1) Like "#" And _
Not Mid(strToCheck, i, 1) Like ":" Then
MsgBox "There is a character that is not a digit or " _
& "a colon at position # " & i & "."
Exit Sub
End If
i = i + 1
Loop While i <= Len(strToCheck)

MsgBox "There are only digits and/or colons in the selection."

End Sub

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE[ at ]CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net