Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > infinite change event over flows


Reply
 
Thread Tools Display Modes
  #1  
Old 11-01-2003, 05:50 PM
Benzakhar Benzakhar is offline
Junior Contributor
 
Join Date: Mar 2003
Posts: 274
Default infinite change event over flows


If I use the textrtf property for the richtextbox then the change event is executed. But in my change event it uses the textrtf property so then there goes an infinite loop witch then results to an over flow. Create a textbox or richtextbox and for the change event put this.

Text1.Text="hello world"

Now there will be an infinite loop. In this example how Can I stop the infinite loop?

Thanx in advance!
Reply With Quote
  #2  
Old 11-01-2003, 05:56 PM
Tristan's Avatar
Tristan Tristan is offline
Regular
 
Join Date: Sep 2003
Posts: 70
Default

Code:
Private Sub Text1_Change() If Text1.Text <> "hello world" Then Text1.Text = "hello world" End If End Sub

This would stop an infinite loop in your test example, but not sure if it can be applied to your problem.
Reply With Quote
  #3  
Old 11-01-2003, 06:19 PM
Benzakhar Benzakhar is offline
Junior Contributor
 
Join Date: Mar 2003
Posts: 274
Default

Thanx for trying but I would not be able to apply that to my project. Iam editing a richtextbox via RTF code. This is much faster than using the .Sel properties. I have managed to successfully do this. Now I need a way to do this when the change event is executed. But in the change event it changes the RTF of the richtextbox thus the change event is executed in an infinite loop. Anyone know a way to stop the infinite loop?

Thanx in advance!
Reply With Quote
  #4  
Old 11-01-2003, 06:36 PM
unclebill unclebill is offline
Junior Contributor
 
Join Date: Apr 2003
Location: San Diego, CA
Posts: 301
Default

Try creating a statc variable in your event handler and check it for a given state or value on entry. If it's in the 'active' state, then immediately exit the event handler.
Code:
Public Text1_Change()
Static Flag as Boolean
   If Flag = True then
      Exit Sub
   End If
   Flag = True
   Your Code
   Flag = False
End Sub
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
datagrid data change failed to fire recordset fieldchangecomplete event? soo123w Database and Reporting 0 10-29-2003 03:06 PM
Change or Key Up Event swervedriver General 4 07-21-2003 05:23 PM
DDE Updates to a text box and its Change Event cbmaxman General 0 10-22-2002 11:28 AM
TextBox Change event? schusters General 3 02-19-2002 06:59 AM
Change event not recognizing Medic General 4 06-07-2001 11:48 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->