PC Review


Reply
Thread Tools Rate Thread

Determine if a TextField has changed...?

 
 
=?Utf-8?B?RGVuaXNl?=
Guest
Posts: n/a
 
      25th Apr 2004
I want to fire code when the user changes the value of a textbox. I only want it to fire when the user is finished eding the TextBox and leaves (not after each keystroke). I am using the Validating event (the Leave even seems similar), but this is called even when the user does not make a change. Is there a simple way to handle this other than manually setting boolean flags for each keystroke?

I also find that the Validating event is begin called even when I do a 'CancelUpdate' to undo the changes - I do not want this to happen. Again, is there a simple solution? Didn't older version of VB have an IsDirty function? Is there something similar

Thanks
Denise
 
Reply With Quote
 
 
 
 
Armin Zingler
Guest
Posts: n/a
 
      25th Apr 2004
"Denise" <(E-Mail Removed)> schrieb
> I want to fire code when the user changes the value of a textbox. I
> only want it to fire when the user is finished eding the TextBox and
> leaves (not after each keystroke). I am using the Validating event
> (the Leave even seems similar), but this is called even when the user
> does not make a change. Is there a simple way to handle this other
> than manually setting boolean flags for each keystroke?
>
> I also find that the Validating event is begin called even when I do
> a 'CancelUpdate' to undo the changes - I do not want this to happen.
> Again, is there a simple solution? Didn't older version of VB have
> an IsDirty function? Is there something similar?


Store the values you want to edit in a data layer (in variables, in an
object). If you leave a textbox, compare the value in the textbox to the
corresponding one in the data layer. You can validate it in the Validating
event, and, if ok, store the new value in the data layer.


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

 
Reply With Quote
 
yEaH rIgHt
Guest
Posts: n/a
 
      25th Apr 2004
Just save the value of the textbox and compare it in the validating event.


Dim lastSaved As String = ""
Private Sub TextBox1_Validating(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles TextBox1.Validating

If TextBox1.Text <> lastSaved Then

'--- Fire your event---
'---------------------

'-- Save to current text
lastSaved = TextBox1.Text
End If

End Sub

Denise wrote:

> I want to fire code when the user changes the value of a textbox. I only want it to fire when the user is finished eding the TextBox and leaves (not after each keystroke). I am using the Validating event (the Leave even seems similar), but this is called even when the user does not make a change. Is there a simple way to handle this other than manually setting boolean flags for each keystroke?
>
> I also find that the Validating event is begin called even when I do a 'CancelUpdate' to undo the changes - I do not want this to happen. Again, is there a simple solution? Didn't older version of VB have an IsDirty function? Is there something similar?
>
> Thanks,
> Denise

 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      25th Apr 2004
Hi Denise,

In addition to the others,

Store on the "Enter" event and check on the "Leave" event.

For this you can make in my opinion a generic routine by adding the handlers
for this in a loop to all your textboxes.

When that is a problem, message back, then I can see if I can make a sample
for you.

I hope this helps?

Cor


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Selection query with MAX(textfield) and WHERE textfield LIKE 'mask Carsten Microsoft Access Queries 5 11th Nov 2008 06:22 PM
use vb to determine last cell changed jck.office@gmail.com Microsoft Excel Programming 10 8th Oct 2008 04:44 AM
Determine if dataset has changed Benj Nunez Microsoft C# .NET 2 7th Jan 2008 12:01 PM
Determine if the sheet has been changed Erik Wikström Microsoft Excel Programming 2 12th Dec 2007 03:00 PM
determine if a cell changed value =?Utf-8?B?RGF2ZTAx?= Microsoft Excel Worksheet Functions 0 8th Jul 2005 04:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:52 PM.