473,395 Members | 1,440 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,395 software developers and data experts.

Avoiding Keyboard Errors

Is there somthing I can use for a text box control that will help
avoid my users of entering "stupid" data. In many cases our user will
enter number such as 10.0 or 0.50 or even 0,45 however if my user
enter ..045 or ,,045 how can i control this and prompt him to re-
enter. I thought of using the replace function however I don;t know
what direction to take with this. Could someone please point me on the
right track???
Feb 27 '08 #1
4 1052
On Feb 27, 6:27 pm, cmdolcet69 <colin_dolce...@hotmail.comwrote:
Is there somthing I can use for a text box control that will help
avoid my users of entering "stupid" data. In many cases our user will
enter number such as 10.0 or 0.50 or even 0,45 however if my user
enter ..045 or ,,045 how can i control this and prompt him to re-
enter. I thought of using the replace function however I don;t know
what direction to take with this. Could someone please point me on the
right track???
Hi,
Replace function can be used, in this sample you may correct incorrect
user entries that are done with " . " instead of
" , ":

If TextBox1.Text.Contains(".") = True Then
TextBox1.Text = TextBox1.Text.Replace(".", ",")
End If
End Sub


Feb 27 '08 #2
On Feb 27, 11:27 am, cmdolcet69 <colin_dolce...@hotmail.comwrote:
Is there somthing I can use for a text box control that will help
avoid my users of entering "stupid" data. In many cases our user will
enter number such as 10.0 or 0.50 or even 0,45 however if my user
enter ..045 or ,,045 how can i control this and prompt him to re-
enter. I thought of using the replace function however I don;t know
what direction to take with this. Could someone please point me on the
right track???
I also should have mentioned you can use the MaskedEditTextBox to
restrict what data can be entered.

Thanks,

Seth Rowe [MVP]
Feb 27 '08 #3
Hi,

Beside the maskededit box is of course the good old but also in .Net
function IsNumeric good enough.

In fact it is an optimized and simple to use TryParse but in my idea more
then good enough for your purpose.

http://msdn2.microsoft.com/en-us/library/6cd3f6w1.aspx

Cor

"cmdolcet69" <co************@hotmail.comschreef in bericht
news:1a**********************************@n58g2000 hsf.googlegroups.com...
Is there somthing I can use for a text box control that will help
avoid my users of entering "stupid" data. In many cases our user will
enter number such as 10.0 or 0.50 or even 0,45 however if my user
enter ..045 or ,,045 how can i control this and prompt him to re-
enter. I thought of using the replace function however I don;t know
what direction to take with this. Could someone please point me on the
right track???
Feb 27 '08 #4
"cmdolcet69" <co************@hotmail.comschrieb:
Is there somthing I can use for a text box control that will help
avoid my users of entering "stupid" data. In many cases our user will
enter number such as 10.0 or 0.50 or even 0,45 however if my user
enter ..045 or ,,045 how can i control this and prompt him to re-
enter.
\\\
Private Sub TextBox1_Validating( _
ByVal sender As Object, _
ByVal e As CancelEventArgs _
) Handles TextBox1.Validating
Dim SourceControl As TextBox = DirectCast(sender, TextBox)
Dim n As Double
If Not Double.TryParse(SourceControl.Text, n) Then
Me.ErrorProvider1.SetError( _
SourceControl, _
"Value must be a double." _
)
Else
If Me.ErrorProvider1.GetError(SourceControl).Length 0 Then
Me.ErrorProvider1.SetError(SourceControl, String.Empty)
End If
...
End If
End Sub
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Feb 27 '08 #5

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

Similar topics

181
by: Tom Anderson | last post by:
Comrades, During our current discussion of the fate of functional constructs in python, someone brought up Guido's bull on the matter: http://www.artima.com/weblogs/viewpost.jsp?thread=98196 ...
1
by: LRD | last post by:
Form not refreshing after autopostback unless keyboard or mouse move Hi, We created several new ASP.NET C# forms for our intranet. In each form we use panels for different sections of the...
13
by: Steve Jorgensen | last post by:
Well, it seems that Microsoft, or whatever powers that be have decided it's time for us to have yet another standard keyboard layout change. I think I see that the point of this one was to reduce...
9
by: Simon | last post by:
Hi All, Is it possible to disallow implicit casting for an operand of a function written in C? i.e. void foo(int a) {..} short b; foo(b) // error without explicit cast
7
by: tiger786 | last post by:
I am new to programming and studying basics in college .Can somebody write a program on this? The program should monitor a possibly infinite stream of characters from the keyboard (standard...
27
by: galt_57 | last post by:
I need to do just a few multiplies of long integers and have a divide by ten. Can I avoid using floats? Can I use two longs as a 64 bit value somehow? Thanks.
27
by: Cephalobus_alienus | last post by:
Hello, I know that macros are evil, but I recently came across a problem that I couldn't figure out how to solve with templates. I wanted to create a set of singleton event objects, and wrote...
1
by: lolly | last post by:
hi i recently used a virtual keyboard from www.codeproject.com/jscript/jvk.asp. However this part of the code function keyb_callback(ch) { var text =...
2
by: MiG | last post by:
Hello, I have the following operators declared in a class: // Provides R/W direct access to the matrix. __forceinline const T& operator(USHORT ndx) const throw() { _ASSERT(ndx < 16);...
5
by: qwert7465 | last post by:
any help would be appreciated. here is my code: // Final Project #include <iostream.h> #include <iomanip.h> void checkout();
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
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
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...

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.