473,387 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Determine if a TextField has changed...?

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
Nov 20 '05 #1
3 1681
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

Nov 20 '05 #2
"Denise" <an*******@discussions.microsoft.com> 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

Nov 20 '05 #3
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
Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: C. Armour | last post by:
Help me, I'm suffering! Situation: I have a load() function which loads a bunch of TextFields with values. There are TextListeners registered for each of these TextFields. Thus, changing the...
1
by: Suresh | last post by:
How do I insert a char into the textfield on the keypress event of another textfield? I have two textboxes, "text1" and "text2". Important: "text1" is outside the table. "text2" is inside...
3
by: Sidney Linkers | last post by:
Hi, I'm trying to make a calculated text field in a query where the textvalue is being populated from multiple records. I already use a VBA function to loop through records and concatenate the...
1
by: platostoteles | last post by:
Hallo NG, I am new to JavaScript and would really appreciate any help to solve my problem. I am using the blow code in my form to validate form fields. What I would like to accomplish is that...
3
by: Cah Sableng | last post by:
Hi all. I am new member of this group. I have a problem with currency formatter function I made. On onkeyup's method of a textfield I add function below: <snip> function formatCurrency(elm)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.