my text_Change runs can I stop this?

Inside that routine, I have something along the lines of

If instr(1,txtinfo(1).text, "A")) =0 and instr(1,txtinfo(1).text, "B")) =0 Then
txtInfo(1).text = "A" & txtinfo(1).text
blah blah blah of course change runs again - not a biggie as the code runs okay, but pointless nonetheless...
LVL 67
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Harisha M GEngineerCommented:
Hi sirbounty,
    You are changing it withing _Change event

Harisha M GEngineerCommented:
Try something like this...

Public Running As Boolean

Private Sub texttnfo_Change()
    If Not Running And (instr(1,txtinfo(1).text, "A")) =0 and instr(1,txtinfo(1).text, "B") )) =0 Then
        txtInfo(1).text = "A" & txtinfo(1).text
        Running = True
        Running = False
    End If
End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Harisha M GEngineerCommented:
    my mistake...

If (Not Running) And (InStr(1,txtinfo(1).Text, "A") =0) And (InStr(1,txtinfo(1).Text, "B") =0) Then
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

You can't stop the Change event from firing again.  Even with the boolean flag you're just ignoring setting the text for a second time, but it does not change the fact that the event is fired twice.
Harisha M GEngineerCommented:
    Yes.. of course... it will prevent the appending of "A" which is the main requirement here. :)
Didn't read what he was doing...a boolean would work okay here (or maybe you can do your handling in another event).
sirbountyAuthor Commented:
Hey guys - good info above.  just want to detail what I'm doing...

User will copy a number from another program.  I want that when it's pasted to my form, it'll be preceeded with an "A" if not already (the originating number doesn't have the "A", but some folks add it before pasting it).

Anyway - I'm going to close this one - I've found another bug that is going to basically eliminate this as an issue anyway...thanx for the input. :^)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.