I use the sub below to detect data entry error. The problem is that users
are still able to move out of the textbox AFTER the sub is run (and error
msg popped up) without having to correct the invalid data. In order to trap
all possible movements, I have to run the sub in Key events and Mouse
events. This is a lot of work.
I guess there must be a way to catch all key/mouse in and out the text box
so that we can run validation once and still be able to force the user to
supply valid data before leaving the textbox.
Any help is greatly appreciated.
Bill
--------------------
Private Sub txtBgross1_Text Changed(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles txtBgross1.Text Changed
Dim bValid As Boolean
bValid = ValidateDataEnt ry(1, Trim(txtBgross1 .Text), "BOL Gross")
If bValid = False Then
txtBgross1.Focu s()
End If
End Sub
Private Function ValidateDataEnt ry(ByVal entryType As Integer, _
ByVal entryVal As String, _
ByVal entrySource As String) As Boolean
Dim bAnsw As Boolean = True
Select Case entryType
Case 1
If IsNumeric(entry Val) = False Then
Beep()
MsgBox(entrySou rce & " must be numeric!", MsgBoxStyle.OKO nly, "Data Entry
Validation")
bAnsw = False
End If
End Select
Return bAnsw
End Function 1 2372
Bill,
One option is to perform input validation in a textbox’s Validating event.
When the user changes the focus from a textbox (or other control) the
textbox’s Validating event occurs.
In the Validating event you can write code to validate the data in the
textbox. If the user has entered invalid data you can inform the user and
cancel the Validating event.
Canceling the textbox’s Validating event prevents the focus from leaving the
textbox. This forces the user to enter good data into the textbox in order to
continue.
Kerry Moorman
"Bill nguyen" wrote: I use the sub below to detect data entry error. The problem is that users are still able to move out of the textbox AFTER the sub is run (and error msg popped up) without having to correct the invalid data. In order to trap all possible movements, I have to run the sub in Key events and Mouse events. This is a lot of work.
I guess there must be a way to catch all key/mouse in and out the text box so that we can run validation once and still be able to force the user to supply valid data before leaving the textbox.
Any help is greatly appreciated.
Bill
--------------------
Private Sub txtBgross1_Text Changed(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles txtBgross1.Text Changed
Dim bValid As Boolean
bValid = ValidateDataEnt ry(1, Trim(txtBgross1 .Text), "BOL Gross")
If bValid = False Then
txtBgross1.Focu s()
End If
End Sub Private Function ValidateDataEnt ry(ByVal entryType As Integer, _
ByVal entryVal As String, _
ByVal entrySource As String) As Boolean
Dim bAnsw As Boolean = True
Select Case entryType
Case 1
If IsNumeric(entry Val) = False Then
Beep()
MsgBox(entrySou rce & " must be numeric!", MsgBoxStyle.OKO nly, "Data Entry Validation")
bAnsw = False
End If
End Select
Return bAnsw
End Function
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: John Champaign |
last post by:
Hi all,
I'm working on an educational applet for a child with special needs.
He's got a bit of a trick to make my life more difficult... To interact
with the applet he needs to click on buttons, which is fine most of the
time (he comes from a Mac environment, so I accept mouse clicks from the
right or left button when he's working on the PC). But every once in a
while, he'll press and hold the right mouse button, move onto a JButton,...
|
by: Aris |
last post by:
Where can I found the way that c++ manipulates mouse events in graphic mode?
thank you.
|
by: DaBo$$ |
last post by:
hi !
I have created a program which move mouse cursor, but i
want to :
1- stop physical mouse move.
2- when a press a keyboard button, execute the same
action if a press the mouse button.
In fact, i want to remplace the physical mouse motion.
|
by: Raj Chudasama |
last post by:
I have a controls similiar to the windows calculator. (Please press some
buttons on your calculator to see what i am talking about)
So when u hover over a button it will change the state (it changes to
different image)
if u click it will show pressed image etc
now the problem:
the calculator does the following
|
by: raj |
last post by:
hi,
i have one textbox and one save button, i have added attribute at page
load event
btnSave.Attributes.Add("onclick","return ValidateForm();");
in validationform() ,I have written like this
if(--some validation function here--)
{
| |
by: Tim Frawley |
last post by:
Source code attached indicates my problem with validation and a button
bar save button.
Fill the Textbox with some text then tab off the control. The message
box will display the text in the textbox from the Validating event.
Now put the focus back on the textbox click the button bar button.
Nothing happens.
The form causes validation is true, so is the button bar and the
control.
|
by: Micky |
last post by:
VB v7.1.3088
NET v1.1.4322 SP1
My mate has a strange problem regarding the ESC key and validation. When he
hits the Cancel button on his form, the form does not validate. This is
correct behaviour of course. However, he also wants this same behaviour when
hitting ESC on the keyboard.
It was my understanding that when you assign a button to a form's
CancelButton property you automatically gained this functionality. However,
|
by: Ryan Liu |
last post by:
Hi,
I need the MouseDown event be trigged everytime when you press mouse in a
datagrid (System.Windows.Forms).
Hi,
I need the MouseDown event be trigged everytime when press mouse in a
datagrid (System.Windows.Forms).
|
by: Roberto Reale |
last post by:
While developing a drag&drop enabled application I found out this
"strange" behaviour: if I put a message box into the QueryContinueDrag
event handler the message box is shown but the mouse cursor is set to
WaitCursor (Hourglass) and I can't click on OK or on X, so that the
only way to close the message box is via the keyboard, by pressing
SPACE key.
The most strange thing is that if I place two message boxes, only the
first one is...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |