MS Office Forum / Word / Programming / January 2005
Like operator not liking it
|
|
Thread rating:  |
Poseur - 18 Jan 2005 06:45 GMT Anyone have an idea why this doesn't work? In my "Document_Open" routine, if the document name format is a certain pattern, e.g. "1499011_1292004.doc", then I want to run certain routines on it: If ActiveDocument.Name Like "[0-9]@_[0-9]@.doc" Then... ' or "[0-9]{6,8}_[0-9]{6,8}.doc"
But it always yields a false. When I just run the standard examples out of Help like: "F" Like "[A-Z]" it comes out True. If I separate it out into variables:
strDocName = ActiveDocument.Name '"1499011_1292004.doc" boolResult = strDocName Like "[0-9]@_[0-9]@.doc" If boolResult Then
Still false. When I assign variables like above and watch the locals, Document.Name is "1499011_1292004.doc" not "C:\Folder\1499011_ 1292004.doc" I've tried escaping the "_" just in case even tho it is not a special character in this system: "\_" or "[_]" or even "[\_]"
What am I missing here?
 Signature Poseur "That's just kooky talk." --Kramer
Sabaka - 18 Jan 2005 11:07 GMT Hi Poseur,
Your subject title is very clever!
For a document named "1499011_1292004.doc", the following returns a True.
Sub Similar() If ActiveDocument.Name Like "#######_#######.doc" Then MsgBox "true" Else MsgBox "false" End If
End Sub
> Anyone have an idea why this doesn't work? > In my "Document_Open" routine, if the document name format is [quoted text clipped - 20 lines] > > What am I missing here? Greg Maxey - 18 Jan 2005 11:34 GMT Sabaka,
Great suggestion. I considered this as well but thought Poseur was wanting a True return for file names with fewer or more numerical characters in the string.
 Signature Greg Maxey/Word MVP A Peer in Peer to Peer Support
> Hi Poseur, > [quoted text clipped - 40 lines] >> Poseur >> "That's just kooky talk." --Kramer Sabaka - 18 Jan 2005 15:41 GMT Hi Greg,
You're right Poseur may be looking for names with more or fewer numbers, but his question refers to a format is that is "a certain pattern, e.g. '1499011_1292004.doc'" (Poseur does not say that the format is "one of several possible patterns). I thought that if Poseur is referring to more than one possible format - and I agree he may be - he could clarify his question. Assuming there is more than one format, knowing what those formats are might suggest other solutions. For instance, if there are only a couple formats, maybe one could AND together they required number of Like comparisons. Is the "_" always in a particular position? If so, maybe it could be cropped out along with the ".doc" and one could test to see if what is left is numeric.
> Sabaka, > [quoted text clipped - 46 lines] > >> Poseur > >> "That's just kooky talk." --Kramer Greg Maxey - 18 Jan 2005 11:30 GMT Poseur,
I only have my head about 3/4 around this Like function. I know two things. It doesn't work like the wildcard strings in Find and Replace and it is extremely frustrating.
"F" Like "[A-Z]" it comes out True because "a character" in the string is in the range A-Z, not all characters as one would expect.
There are no @ or { } in your string so the return is false. There is apparently no @ one or more like the preceeeding or { } feature in the Like statement similiar to find and replace.
Try this. It isn't perfect, but it returns true for the example you gave.
Example Sub Test() Dim myString As String Dim Result As String
myString = "1490212_456789.doc" Result = Not myString Like "*[!0-9_]*.doc"
MsgBox Result End Sub
 Signature Greg Maxey/Word MVP A Peer in Peer to Peer Support
> Anyone have an idea why this doesn't work? > In my "Document_Open" routine, if the document name format is [quoted text clipped - 20 lines] > > What am I missing here? Helmut Weber - 18 Jan 2005 12:41 GMT Hi Greg,
>It isn't perfect, but pretty hard to show, that you are right, like
myString = "2_.doc" myString = "_.doc" myString = "1_1_6.doc" myString = "_2.doc"
In linguistics, a set of rules, that define allowed sequences of characters, is called a "grammar". I a very simplified way. ;-)
For cases like this one, I built my own little grammar, in pseudocode:
false if right(4) <> ".doc" ' set the starting part to a variable s false if in s there isn't exactly 1 underscore false if the underscore is at the leftmost position of s false if the underscore is at the rightmost position of s etc. etc.
Sure, the problem is solvable. But that's no challenge. The challenge might be: a) What is the most effective algorithm regarding speed? Impossible to anwer, whithout knowing about the most often occurring errors! b) What is the shortest way of coding? I love short code. But whether it always leads to faster execution, I don't know. And whether it leads to better understanding, would be another question.
Great fun twisting brains!
Greetings from Bavaria, Germany
Helmut Weber, MVP "red.sys" & chr(64) & "t-online.de" Word XP, Win 98 http://word.mvps.org/
Greg - 18 Jan 2005 14:07 GMT Helmut,
Nearer to perfect but far from pretty:
Sub Test() Dim myString As String Dim intResult As Boolean Dim Result As Boolean Dim i As Long Dim j As Long myString = "14_9012456789.doc" i = Len(myString) intResult = Not myString Like "*[!0-9_]*.doc" myString = Left(myString, i) j = InStr(myString, "_") Result = j <> 0 Result = InStr(j + 1, myString, "_") = 0 And j > 1 And j < i And intResult
MsgBox Result End Sub
Greg - 18 Jan 2005 16:31 GMT Helmut,.
Now that the morning cob webs have cleared, I think that this comes closer to meeting satisfying the conditions that the file is a .doc file, the name consists of a series of numbers spilt with a single _.
The _ can not be the first or last character in the file name.
Sub Test() Dim myString As String Dim A, B, C, D, Result As Boolean Dim i As Long Dim j As Long myString = "149012_456789.doc" i = Len(myString) A = Right(myString, 4) Like ".doc" B = Not Left(myString, i - 4) Like "*[!0-9_]*" j = InStr(myString, "_") C = j <> 0 And j <> 1 And j <> i - 4 D = InStr(j + 1, myString, "_") = 0 Result = A And B And C And D MsgBox Result End Sub
Helmut Weber - 18 Jan 2005 22:12 GMT Hi Greg, how about myString = "149012_456789.Doc" or other mixtures of capital and ordinary letters? Seems "like", in this case, doesn't do anything.
I'd recommend an additional lcase().
By the way, the expression, based on Jonathan's suggestion, B = Not Left(myString, i - 4) Like "*[!0-9_]*" would be worth an extra article on the MVP pages, maybe in a new section, "for the very, very advanced".
I wish I knew, whether I understand it.
Greetings from Bavaria, Germany
Helmut Weber, MVP "red.sys" & chr(64) & "t-online.de" Word XP, Win 98 http://word.mvps.org/
Greg Maxey - 18 Jan 2005 22:53 GMT Helmut,
Yep, I added the lcase
B = Not Left(myString, i - 4) Like "*[!0-9_]*"
My understanding is: "If" any character in the sting is "not" (signified by the "!") in the range
0-9 or a _ then the Like statement is true.
e.g.,
B = 1234A Like "*[!0-9_]*" = True ergo
B = Not 1234A Like "*[!0-9_]*" = False
B = 1234 Like "*[!0-9_]" = False because no single character in the string is not in the range
0-9_ ergo
B = Not 1234 Like "*[!0-9_]" = True
Similarly,
B = A123456 Like "*[A-Z]*" = True because at least one character in the string is in the range.
That is my current understanding. I admit that I only have my head about 3/4 around this idea at present.
 Signature Greg Maxey/Word MVP A Peer in Peer to Peer Support
> Hi Greg, > how about [quoted text clipped - 17 lines] > Word XP, Win 98 > http://word.mvps.org/ Jeff - 18 Jan 2005 23:13 GMT Try this as a brute force way to do it
Maybe I'm stupid but I thought you needed a "[0-9]" for EACH character that needs to be tested. I can't see you "@" operator documented in Word 2000
Sub TEST_Like() Dim a, b, i, j, sCompare a = "1499011_1292004.doc"
sCompare = "" j = Len(a) - 4 For i = 1 To j If Mid(a, i, 1) = "_" Then sCompare = sCompare + "_" Else sCompare = sCompare + "[0-9]" End If Next sCompare = sCompare + ".doc"
b = a Like sCompare MsgBox sCompare MsgBox b
End Sub
> Hi Greg, > how about [quoted text clipped - 17 lines] > Word XP, Win 98 > http://word.mvps.org/ Greg Maxey - 18 Jan 2005 23:30 GMT Jeff,
Stupid? Far from it. Your method is neat. In the particular question Helmut and I are discussing it misses a few conditions. The conditions are:
The file name is numbers and a single underscore character. It has to have one and only one underscore and the underscore can't be the first or last character in the file name. This works:
Sub TextComparison() Dim myString As String Dim A, B, C, D, Result As Boolean Dim i As Long Dim j As Long myString = "149012_456789.doc" 'change to test i = Len(myString) A = LCase(Right(myString, 4)) Like ".doc" B = Not Left(myString, i - 4) Like "*[!0-9_]*" j = InStr(myString, "_") C = j <> 0 And j <> 1 And j <> i - 4 D = InStr(j + 1, myString, "_") = 0 Result = A And Bb And C And D MsgBox Result End Sub
 Signature Greg Maxey/Word MVP A Peer in Peer to Peer Support
> Try this as a brute force way to do it > [quoted text clipped - 44 lines] >> Word XP, Win 98 >> http://word.mvps.org/ Jeff - 19 Jan 2005 10:46 GMT Oh yes, I'd sort of skipped those extra constraints!
I acknowledge your method works but to my way of thinking, it's too sophisticated :-)) to be easily maintained
However, this modified solution works:
Sub TEST_Like() Dim a, b, i, j, sCompare, bUnderscore a = "1499011_1292004.doc"
sCompare = "" bUnderscore = False j = Len(a) - 4 For i = 1 To j If Mid(a, i, 1) = "_" and i <> 1 and bUnderscore = False Then sCompare = sCompare + "_" bUnderscore = True Else sCompare = sCompare + "[0-9]" End If Next sCompare = sCompare + ".doc"
b = a Like sCompare MsgBox sCompare MsgBox b
End Sub
> Jeff, > [quoted text clipped - 70 lines] > >> Word XP, Win 98 > >> http://word.mvps.org/ Greg Maxey - 19 Jan 2005 11:03 GMT Jeff,
Close. Added one more condition to your mid statement
If Mid(a, i, 1) = "_" And i <> 1 And i <> j And _ bUnderscore = False Then
That way the _ can't be the first or "last" character in the string.
Complicated? Thinkers can always think differently :-)
 Signature Greg Maxey/Word MVP A Peer in Peer to Peer Support
> Oh yes, I'd sort of skipped those extra constraints! > [quoted text clipped - 104 lines] >>>> Word XP, Win 98 >>>> http://word.mvps.org/ Andi Mayer - 19 Jan 2005 13:27 GMT I could't resist now :
Function isMyPattern(myString As String) As Boolean Dim I As Long, L As Long, J As Long
If StrComp(Right(myString, 4), ".doc", vbTextCompare) Then Exit Function End If L = Len(myString) - 4 For I = 1 To L J = Asc(Mid(myString, I, 1)) If J = 95 Then If I = L Or I = 1 Then Exit Function ElseIf J < 48 Or J > 57 Then Exit Function End If Next isMyPattern = True
End Function
--- If you expect an answer to a personal mail, add the word "manfred" to the first 10 lines in the message MW
Greg - 19 Jan 2005 13:53 GMT Andi,
Interesting approach. I took the liberty to alter slightly. You didn't catch the condition that there must be one and only one underscore in the test string:
Sub TextCompare() Dim I As Long, L As Long, J As Long, K As Long, myString As String
myString = "121_345.doc" 'alter to test
If StrComp(Right(myString, 4), ".doc", vbTextCompare) Then Exit Sub End If L = Len(myString) - 4 For I = 1 To L J = Asc(Mid(myString, I, 1)) If J = 95 Then K = K + 1 If I = L Or I = 1 Then Exit Sub ElseIf J < 48 Or J > 57 Then Exit Sub End If Next If K = 0 Or K > 1 Then Exit Sub MsgBox "True" End Sub
Andi Mayer - 19 Jan 2005 14:45 GMT >Andi, > >Interesting approach. I took the liberty to alter slightly. You didn't >catch the condition that there must be one and only one underscore in >the test string: you welcome, it's free code (otherwise I would have send you a dll)
then you should back-out if K=2 do avoid the rest
If J = 95 Then if K =1 then exit sub else K = 1
and then you hav only to chek for K=0
>Sub TextCompare() >Dim I As Long, L As Long, J As Long, K As Long, myString As String [quoted text clipped - 17 lines] >MsgBox "True" >End Sub --- If you expect an answer to a personal mail, add the word "manfred" to the first 10 lines in the message MW
Andi Mayer - 19 Jan 2005 14:51 GMT another approach:
Function isMyPattern1(ByVal myString As String) As Boolean Dim I As Long For I = 0 To 9 myString = Replace(myString, I, "") Next
If StrComp(myString, "-.doc", vbTextCompare) Then MsgBox "True" End If isMyPattern1 = True
End Function
--- If you expect an answer to a personal mail, add the word "manfred" to the first 10 lines in the message MW
Greg - 19 Jan 2005 16:00 GMT Andi,
Can't get my head around this method. Yes it returns true for 123_567.doc, but it also returns true for variations with letters or more than one underscore.
Andi Mayer - 19 Jan 2005 16:17 GMT >Andi, > >Can't get my head around this method. Yes it returns true for >123_567.doc, but it also returns true for variations with letters or >more than one underscore. opps fogot a "tiny bit"
If StrComp(myString, "-.doc", vbTextCompare) = 0 Then
if both string are the same then its 0 else its a noneZero
-1 (true) means string1 is less than string2 --- If you expect an answer to a personal mail, add the word "manfred" to the first 10 lines in the message MW
Andi Mayer - 19 Jan 2005 16:23 GMT >Andi, > >Can't get my head around this method. Yes it returns true for >123_567.doc, but it also returns true for variations with letters or >more than one underscore. I should paste the whole function and not part of it, then I hope I will get it right
Function isMyPattern1(ByVal myString As String) As Boolean Dim I As Long For I = 0 To 9 myString = Replace(myString, I, "") Next
If StrComp(myString, "_.doc", vbTextCompare) = 0 Then isMyPattern1 = True End If
End Function
--- If you expect an answer to a personal mail, add the word "manfred" to the first 10 lines in the message MW
Jean-Guy Marcil - 19 Jan 2005 17:06 GMT Andi Mayer was telling us: Andi Mayer nous racontait que :
>> Andi, >> [quoted text clipped - 16 lines] > > End Function My turn... I couldn't resist either!
You are still missing the underscore position condition (It cannot be first or last in the name)
With this very simple modification, I think it meets all the requirements:
'_______________________________________ Sub Test()
Dim Checked As Boolean
Checked = isMyPattern1("123_567.doc")
End Sub '_______________________________________
'_______________________________________ Function isMyPattern1(ByVal myString As String) As Boolean
Dim i As Long Dim FirstCar As String Dim LastCar As String
FirstCar = Mid(myString, 1, 1) LastCar = Mid(myString, Len(myString) - 4, 1)
If FirstCar = "_" Or LastCar = "_" Then isMyPattern1 = False Exit Function Else For i = 0 To 9 myString = Replace(myString, i, "") Next If StrComp(myString, "_.doc", vbTextCompare) = 0 Then isMyPattern1 = True End If End If
End Function '_______________________________________
 Signature Salut! _______________________________________ Jean-Guy Marcil - Word MVP jmarcilREMOVE@CAPSsympatico.caTHISTOO Word MVP site: http://www.word.mvps.org
Helmut Weber - 19 Jan 2005 18:02 GMT Hi Jean-Guy, hi Andy, hi Greg,
hi all co-readers and co-thinkers,
iT's getting better with every new contribution.
I specially like the idea
For I = 0 To 9 myString = Replace(myString, I, "") Next
Nice day to you all.
Imagine, what it would mean to set up rules like that for a natural language, besides of the fact, that a natural language changes every minute.
Greetings from Bavaria, Germany
Helmut Weber, MVP "red.sys" & chr(64) & "t-online.de" Word XP, Win 98 http://word.mvps.org/
Greg - 19 Jan 2005 17:12 GMT Andi,
I like it :-). Again I took the liberty to alter and include the condition that the _ is not the first or last character in the file name:
Function StrCompare5(ByVal myString As String) As Boolean Dim i As Long Dim oLen As Long oLen = Len(myString) - 4 If InStr(myString, "_") = 1 Or _ InStr(myString, "_") = oLen Then Exit Function For i = 0 To 9 myString = Replace(myString, i, "") Next If StrComp(myString, "_.doc", vbTextCompare) = 0 Then StrCompare5 = True End If End Function
Andi Mayer - 19 Jan 2005 17:34 GMT Jean-Guy and Greg:
nobody is perfect ( and I am for sure a nobody)
now it would be interesting which one is faster --- If you expect an answer to a personal mail, add the word "manfred" to the first 10 lines in the message MW
Jeff - 19 Jan 2005 18:03 GMT > nobody is perfect I hope you're not including me in that :-)) My wife not only thinks I'm perfect, she KNOWS it!
PS Did I mention I'm a hypnotist in my spare time :-))))
Jeff
<fx Little Britain> "Look into my eyes. Don't look around my eyes, look into my eyes. When I count to three you will realise your method is rubbish and you will tell everyone how GREAT Jeff's method is... 1, 2, 3...!"
Greg - 19 Jan 2005 18:30 GMT Andi,
All six methods here are less than 1 second. The timer returns 0 for each one.
Poseur, Sabaka, Helmut, Jeff, JGM, and Andi
Thanks for the discussion on this topic. I have learned alot just playing around with each of your suggestions. I have put together six solutions using some or all of your suggestions. I suppose that I would have to cast my lot for the method proposed by Poseur the OP, as it would be the easiest to adapt to aditional conditions. I will be firmly hooked on this method once I learn a little more about it.
Sub CallStringCompare() Dim MyString As String
MyString = InputBox("Enter a test string") 'Is the string in the form 123_456.doc? With one or more numbers 'on each side of a single _ character. MsgBox ("The string match is " & StrCompare1(MyString)) MsgBox ("The string match is " & StrCompare2(MyString)) MsgBox ("The string match is " & StrCompare3(MyString)) MsgBox ("The string match is " & StrCompare4(MyString)) MsgBox ("The string match is " & StrCompare5(MyString)) MsgBox ("The string match is " & StrCompare6 _ (MyString, "[0-9]{1,}_[0-9]{1,}.doc"))
End Sub Function StrCompare1(MyString As String) As Boolean Dim A, B, C As Boolean Dim i, j As Long
If StrComp(Right(MyString, 4), ".doc", vbTextCompare) Then Exit Function End If i = Len(MyString) A = Not Left(MyString, i - 4) Like "*[!0-9_]*" j = InStr(MyString, "_") B = j <> 0 And j <> 1 And j <> i - 4 C = InStr(j + 1, MyString, "_") = 0 StrCompare1 = A And B And C End Function Function StrCompare2(MyString As String) As Boolean Dim oChrNum, i, j, k As Long Dim tmpString As String Dim A, B As Boolean
If StrComp(Right(MyString, 4), ".doc", vbTextCompare) Then Exit Function End If For i = 1 To Len(MyString) - 4 oChrNum = Asc(Mid(MyString, i, 1)) If oChrNum >= 48 And oChrNum <= 57 Or oChrNum = 95 Then tmpString = tmpString + Chr(oChrNum) End If Next i A = MyString = tmpString & ".doc" j = InStr(MyString, "_") k = InStr(j + 1, MyString, "_") B = j <> 0 And j <> 1 And j <> Len(MyString) - 4 And k = 0 StrCompare2 = A And B
End Function Function StrCompare3(MyString As String) As Boolean Dim sCompare As String Dim i, j As Long Dim bUnderscore As Boolean
If StrComp(Right(MyString, 4), ".doc", vbTextCompare) Then Exit Function End If sCompare = "" bUnderscore = False j = Len(MyString) - 4 For i = 1 To j If Mid(MyString, i, 1) = "_" And i <> 1 And i <> j And _ bUnderscore = False Then sCompare = sCompare + "_" bUnderscore = True Else sCompare = sCompare + "[0-9]" End If Next sCompare = sCompare + ".doc" StrCompare3 = MyString Like sCompare And bUnderscore End Function Function StrCompare4(MyString As String) As Boolean Dim i, j, k, oLen As Long
If StrComp(Right(MyString, 4), ".doc", vbTextCompare) Then Exit Function End If oLen = Len(MyString) - 4 For i = 1 To oLen j = Asc(Mid(MyString, i, 1)) If j = 95 Then k = k + 1 If i = oLen Or i = 1 Or k > 1 Or k = 0 Then Exit Function End If ElseIf j < 48 Or j > 57 Then Exit Function End If Next StrCompare4 = True
End Function Function StrCompare5(ByVal MyString As String) As Boolean Dim i As Long Dim oLen As Long oLen = Len(MyString) - 4 If InStr(MyString, "_") = 1 Or _ InStr(MyString, "_") = oLen Then Exit Function For i = 0 To 9 MyString = Replace(MyString, i, "") Next If StrComp(MyString, "_.doc", vbTextCompare) = 0 Then StrCompare5 = True End If End Function Function StrCompare6(MyString As String, Pattern As String) As Boolean Dim rgX As VBScript_RegExp_55.RegExp Set rgX = New VBScript_RegExp_55.RegExp With rgX .Pattern = Pattern StrCompare6 = .Test(MyString) End With End Function
Jeff - 19 Jan 2005 19:06 GMT You may be interested to know that Function StrCompare6 is incompatible with Word 2000. VBScript_RegExp_55.RegExp is an unknown type declaration
Greg - 19 Jan 2005 19:32 GMT Jeff,
It works here. Did you install the reference library using Tool>References in the VB Editor?
Jeff - 20 Jan 2005 13:51 GMT I didn't even know about Tools>References!
There are hundreds of unchecked options there! Which one in the library you are referring to?
(Goes away to see if there is any online help to explain Tools>References)
> It works here. Did you install the reference library using > Tool>References in the VB Editor?
>> You may be interested to know that Function StrCompare6 is incompatible >> with Word 2000. VBScript_RegExp_55.RegExp is an unknown type declaration Greg - 20 Jan 2005 17:04 GMT Microsoft VBScript Regular Expressions 5.5
Andi Mayer - 19 Jan 2005 20:39 GMT I am proudly present the results:
10000 runs messages in miliseconds: diff means end-start time AMD 900, winXP
mystring:1490124_56789.doc 1 Diff: 150 2 Diff: 531 3 Diff: 460 4 Diff: 281 5 Diff: 961 6 Diff: 3646
mystring:1490124_56789.doc 1 Diff: 140 2 Diff: 551 3 Diff: 450 4 Diff: 281 5 Diff: 951 6 Diff: 3635 --- If you expect an answer to a personal mail, add the word "manfred" to the first 10 lines in the message MW
Poseur - 19 Jan 2005 01:06 GMT > Anyone have an idea why this doesn't work? > In my "Document_Open" routine, if the document name format is > a certain pattern, e.g. "1499011_1292004.doc", then I want to > run certain routines on it: > If ActiveDocument.Name Like "[0-9]@_[0-9]@.doc" Then... > ' or "[0-9]{6,8}_[0-9]{6,8}.doc" Ok, here's my easy fix. Maybe a cop out but I was getting lost with all those double negatives:
If checkName(.Name, "[0-9]{6,8}_[0-9]{6,8}\.doc") Then ... End If
Function checkName(nm As String, ptrn As String) As Boolean Dim rgX As VBScript_RegExp_55.RegExp Set rgX = New VBScript_RegExp_55.RegExp With rgX .Pattern = ptrn revCase = .Test(nm) End With End Function
Works good.
 Signature Poseur "That's just kooky talk." --Kramer
Greg - 19 Jan 2005 18:02 GMT Poseur,
I managed to get your method to work, but I am in a fog as to how it works. What is revCase and where would a person go to learn how to apply this reference tool?
Thanks.
Jeff - 19 Jan 2005 18:11 GMT In that case don't use it! You or your successor may need to modify it in the future and then you'll be stuffed.
If I seem to be ranting about this point it's because I cut my teeth in programming using a nightmare matrix language (IIRC) called "APL" The only way to modify many of the lines of code was to rewrite them because they were personal "idioms" of their original creators
> Poseur, > [quoted text clipped - 3 lines] > > Thanks. Poseur - 20 Jan 2005 03:05 GMT > In that case don't use it! You or your successor may need > to modify it in the future and then you'll be stuffed. [quoted text clipped - 12 lines] >> >> Thanks. You must be about my age. My CS 101 course was in APL, 1973. That was when you had to enter those IBM punchcards in a remote terminal and turnaround was anywhere from 5 minutes to 3 hours.
 Signature Poseur "That's just kooky talk." --Kramer
Jeff - 20 Jan 2005 13:51 GMT Yes and when we had a single line on-screen editor we thought we were in heaven! I remember having to type two characters on the keyboard to create one character of APL. (I'm 50 BTW)
> > In that case don't use it! You or your successor may need > > to modify it in the future and then you'll be stuffed. [quoted text clipped - 16 lines] > That was when you had to enter those IBM punchcards in a remote > terminal and turnaround was anywhere from 5 minutes to 3 hours. Jean-Guy Marcil - 19 Jan 2005 18:37 GMT Greg was telling us: Greg nous racontait que :
> Poseur, > > I managed to get your method to work, but I am in a fog as to how it > works. What is revCase and where would a person go to learn how to > apply this reference tool? Hi Greg, I was as curious as you were, here is what I found as a reference: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/v sobjRegExp.asp
Like you, I am not sure what revCase is doing there, I would have thought that checkName should be taking revCase's place...
 Signature Salut! _______________________________________ Jean-Guy Marcil - Word MVP jmarcilREMOVE@CAPSsympatico.caTHISTOO Word MVP site: http://www.word.mvps.org
Greg - 19 Jan 2005 18:55 GMT JGM,
I found this also: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnclinic/html/s cripting051099.asp
Which provides some good information.
revCase must have been something unique in Poseur's code. I changed it to the StrCompare6 in my version posted earlier.
This has been a great learning experience. Like school of the boat :-)
Poseur - 20 Jan 2005 03:02 GMT > Poseur, > [quoted text clipped - 3 lines] > > Thanks. Error. Sorry. I was dummying it out but left a business rule specific name in there. Should be:
Function checkName(nm As String, ptrn As String) As Boolean Dim rgX As VBScript_RegExp_55.RegExp Set rgX = New VBScript_RegExp_55.RegExp With rgX .Pattern = ptrn checkName = .Test(nm) End With End Function
As for using the RegExp object in general, it's outlined in the VBScript help file, VBScrip5.chm. Regular expressions in general, I suspect you know. If not, many references out there.
 Signature Poseur "That's just kooky talk." --Kramer
Greg Maxey - 20 Jan 2005 03:03 GMT Hi,
Yes, I found an article on the MSDN site. Thanks.
 Signature Greg Maxey/Word MVP A Peer in Peer to Peer Support
>> Poseur, >> [quoted text clipped - 20 lines] > Regular expressions in general, I suspect you know. If not, many > references out there. Poseur - 24 Jan 2005 03:10 GMT > Poseur, > [quoted text clipped - 3 lines] > > Thanks. Again, sorry. "Revcase" is a mistake, an incomplete cleanup. Should be: Function checkName(nm As String, ptrn As String) As Boolean Dim rgX As VBScript_RegExp_55.RegExp Set rgX = New VBScript_RegExp_55.RegExp With rgX .Pattern = ptrn revCase = .Test(nm) End With End Function
 Signature Poseur "That's just kooky talk." --Kramer
|
|
|