Re: Helmut Weber -- Info please by Phil
Phil
Sat Jul 23 11:01:02 CDT 2005
OK,
Let me get this straight -- you lost your car while trying to find your
pants, because you couldn't remember where the beer party was supposed to be?
As I said I inherited a number of these when an employee left on 3 days
notice. I've "dabbled" with Fortran (pre-77), Focal, PL/1, PL/C, RPG II,
Prolog, PASCAL,COBOL, APL, dBase III+ script, SQL, Basic, CBasic, and a
couple of others. Plus, I know about Zone and Fileld Punches AND the
difference between an O29 and a 129.
The ByRef was a quick and dirty way of making something work. I was and am
dealing with a production item that is used 5 days a week, 52 weeks a year.
I can play with a copy all I want, but the MAIN template MUST work. I also,
trew all my careful Variable initialization and testing out the window. One
of those grab a fistful of band-aids and start to patch deals. I never
really have had a chance to sit and think the whole thing through. I have
about 80 macro's that do basically the same thing, but have the same few
lines of code repeated over and over and over. Plus many cases of ADDs,
DELETEs and Changes -- all undocumented, that have occasionally left stray
code hanging around.
Sorry for the rant, just to let you know that I was trained better, but was
given a '62 Beetle that hadn't been cared for and MUST make it work, no
matter how much wire, twine and chewing gum is required. I know a full
re-write is in order.
Thanks for the assist, you'll probably see more postings as I go.
Phil Montgomery
"Helmut Weber" wrote:
> Hi Phil,
>
> in my humble opinion,
>
> you were trapped by the oddities of VB and VBA,
> and maybe it is the same in other MS languages,
> where true can be written, in a way, as -1.
> msgbox Clng(true) ' -1
>
> When I was using Borland Pascal and other long forgotten languages
> like Prolog and Lisp, I think, True was 1 and false was 0.
>
> In addition, using datatype variant throughout instead of
> declaring datatypes is not a good idea.
>
> To be more precise, if you use "true" (-1), when calling your sub,
> this evaluates to "false" according to your code,
> as it is not equal 1!
>
> I reshuffled you code a bit,
> used variable names according to my very personal taste,
> as you see, they are all 6 characters long, whereby the
> first three characters indicate the data type,
> and suggest,
> to clear search options before calling your sub for the first time,
> and resetting options again after calling it for the last time.
>
> Sub SearchReplace( _
> strOld As String, strNew As String, _
> blnFwd As Boolean, blnFrm As Boolean, _
> blnCas As Boolean, blnWrd As Boolean, _
> blnAll As Boolean)
>
> With Selection.Find
> .Text = strOld
> .Replacement.Text = StrNew
> .Forward = blnFwd
> .Format = blnFrm
> .MatchCase = blnCas
> .MatchWholeWord = blnWrd
> If blnAll Then
> .Execute Replace:=wdReplaceAll
> Else
> .Execute
> End If
> End With
> End Sub
> ' ---
> Sub TestSearchReplace()
> ResetSearch
> Call SearchReplace("Flesh Seeded", "FLESH SEEDED", -1, -1, -1, -1, -1)
> ' is the same as
> Call SearchReplace("Flesh Seeded", "FLESH SEEDED", True, True, True,
> True, True)
> ResetSearch
> End Sub
> ' ---
> Public Sub ResetSearch()
> With Selection.Find
> .ClearFormatting
> .Replacement.ClearFormatting
> .Text = ""
> .Replacement.Text = ""
> .Forward = True
> .Wrap = wdFindContinue
> .Format = False
> .MatchCase = False
> .MatchWholeWord = False
> .MatchWildcards = False
> .MatchSoundsLike = False
> .MatchAllWordForms = False
> ' plus some more if needed
> .Execute
> End With
> End Sub
>
> Beware of linebreaks by the newsreader.
>
>
> Greetings from Bavaria,
> a region in Europe,
> country of BMW, Oktoberfest, Levi Strauss and Alois Alzheimer
> lol ;-)
>
> Helmut Weber, MVP, WordVBA
>
> Win XP, Office 2003
> "red.sys" & Chr$(64) & "t-online.de"
>
>
>
>
>