|
-
Apr 24th, 2002, 07:12 AM
#1
Thread Starter
Lively Member
how do i make a period instead of a comma if it's at the end of the textbox?
when one of my checkboxes is checked, it adds something to my textbox in the format "phrase." how do can i make the period turn into a comma then phrase and then a period (, phrase.) if it's the last item in the textbox?
i've tried this and all i get is an infinite loop where the textbox keeps filling up with empty strings:
Code:
Private Sub ListTxt_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PreviewTxt.TextChanged
Dim Flag As Boolean
Flag = False
If Flag = False Then PreviewTxt.Text = PreviewTxt.Text.Replace(".", ", ")
If PreviewTxt.Text.EndsWith(".") = False Then
PreviewTxt.Text += "."
Flag = True
End If
End Sub
(the flag was to try to avoid the infinite loop)
-
Apr 24th, 2002, 08:50 AM
#2
Hyperactive Member
Instead of the Flag, try Exit Sub. I know tons of ppl out there will say both are ugly both they both work !
William T
Software Architect / Chief Software Developer
Softwaremaker.Net Pte Ltd
http://www.Softwaremaker.net
*** Things are always the darkest before they go pitch black ***
-
Apr 24th, 2002, 09:08 AM
#3
Hyperactive Member
I see your problem...
Your Flag was declared locally within the Sub and therefore loses scope after the End Sub and when your text changes again, your variable is re-initialized to FALSE all over again. In other words, your Flag will always be false when the flow goes into the routine. You therefore get an endless loop. Either declare the FLAG to be of a private scope within the form class or EXIT SUB to terminate the routine flow.
William T
Software Architect / Chief Software Developer
Softwaremaker.Net Pte Ltd
http://www.Softwaremaker.net
*** Things are always the darkest before they go pitch black ***
-
Apr 24th, 2002, 09:15 AM
#4
Hyperactive Member
To deter the perfectionists out there criticizing , the FLAG doesnt just lose its scope, its life is terminated when the routine it is declared in is terminated. Therefore your FLAG will always be initialized as FALSE as you enter the routine again.
Your local DIMension variable is the monkey wrench
William T
Software Architect / Chief Software Developer
Softwaremaker.Net Pte Ltd
http://www.Softwaremaker.net
*** Things are always the darkest before they go pitch black ***
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|