I want to be able to accept a value in "goToTextBox.Text" if it is a decimal
value such as 3.4. My Try statement currently catches non-numeric or blank
data, which I want to retain. How can I accomplish this?
T.I.A.
Grant
Try
Dim goToInteger As Integer = Integer.Parse(goToTextBox.Text) - 1
If goToInteger < 0 Or goToInteger > countInteger Then
Statements........
Else
Statements........
End If
Catch theException As Exception
MessageBox.Show("Non numeric data or blank field.", "Selection
Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
With goToTextBox
.Focus()
.SelectAll()
End With
End Try 4 2697
See textbox.validating event
"Grant" <da*******@hotmail.com> wrote in message
news:2v*************@uni-berlin.de... I want to be able to accept a value in "goToTextBox.Text" if it is a decimal value such as 3.4. My Try statement currently catches non-numeric or blank data, which I want to retain. How can I accomplish this?
T.I.A. Grant Try Dim goToInteger As Integer = Integer.Parse(goToTextBox.Text) - 1
If goToInteger < 0 Or goToInteger > countInteger Then Statements........
Else Statements........
End If Catch theException As Exception MessageBox.Show("Non numeric data or blank field.", "Selection Error", MessageBoxButtons.OK, MessageBoxIcon.Error) With goToTextBox .Focus() .SelectAll() End With End Try
Strictly speaking you shouldn't be trying to throw an exception here as there
is quite an overhead involved in raising exceptions...
I would use a boolean flag, something like:
Dim isGood As Boolean
isGood = False
If CInt(goToTextBox.Text) Then
isGood = True
Else
isGood = False
End If
If CDbl(goToTextBox.Text) Then
isGood = True
Else
isGood = False
End If
If Not isGood Then
MsgBox etc...
End If
HTH
"Grant" wrote: I want to be able to accept a value in "goToTextBox.Text" if it is a decimal value such as 3.4. My Try statement currently catches non-numeric or blank data, which I want to retain. How can I accomplish this?
T.I.A. Grant Try Dim goToInteger As Integer = Integer.Parse(goToTextBox.Text) - 1
If goToInteger < 0 Or goToInteger > countInteger Then Statements........
Else Statements........
End If Catch theException As Exception MessageBox.Show("Non numeric data or blank field.", "Selection Error", MessageBoxButtons.OK, MessageBoxIcon.Error) With goToTextBox .Focus() .SelectAll() End With End Try
Hi,
A suggestion :
If IsNumeric(goToTextBox.Text) Then
Statements........
Else
MessageBox.Show("Non numeric data or blank field.", "Selection Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
With goToTextBox
.Focus()
.SelectAll()
End With
End If
Hope this help; Regards.
"Grant" <da*******@hotmail.com> a écrit dans le message de news: 2v*************@uni-berlin.de... I want to be able to accept a value in "goToTextBox.Text" if it is a decimal value such as 3.4. My Try statement currently catches non-numeric or blank data, which I want to retain. How can I accomplish this?
T.I.A. Grant Try Dim goToInteger As Integer = Integer.Parse(goToTextBox.Text) - 1
If goToInteger < 0 Or goToInteger > countInteger Then Statements........
Else Statements........
End If Catch theException As Exception MessageBox.Show("Non numeric data or blank field.", "Selection Error", MessageBoxButtons.OK, MessageBoxIcon.Error) With goToTextBox .Focus() .SelectAll() End With End Try
"MN at2 dot3 >" <1<n.m-recrut1ifrance2com3> schrieb: A suggestion :
If IsNumeric(goToTextBox.Text) Then Statements........
Notice that 'IsNumeric' will return 'True' for all valid numbers, but
doesn't take account if the number represented by the string can be stored
(parsed) in a certain numeric data type.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: White Wolf |
last post by:
Hi,
I cannot believe my eyes, but so far I could not find out what is the name
of the construct, which is built from one try block and the catch clauses
(handlers). I am not looking for a...
|
by: Arjen |
last post by:
Hi,
I'm doing this:
try {
try {
}
catch(Exception ex){
throw;
|
by: VB Programmer |
last post by:
Variable scope doesn't make sense to me when it comes to Try Catch Finally.
Example: In order to close/dispose a db connection you have to dim the
connection outside of the Try Catch Finally...
|
by: Woody Splawn |
last post by:
I have a try catch statement in a fucntion that is supposed to return a true
or a false
My code looks like this:
Try
mySqlConnection.Open()
Dim Da1 As New SqlDataAdapter("Select JnlType,...
|
by: Patrick Dickey |
last post by:
Hello, All!
I'm modifying some source code that I downloaded from
Planet-source-code a while back, and have a question about Try Catch
statements. Basically, I'm wondering if I can do a Try with...
|
by: zacks |
last post by:
The help isn't clear on this. If I have multiple catches and the first
one catches the particular exception that was thrown, does it check the
rest of the catches in the try/catch?
For example,...
|
by: cj |
last post by:
Another wish of mine. I wish there was a way in the Try Catch structure
to say if there wasn't an error to do something. Like an else
statement. Try Catch Else Finally.
Also because I...
|
by: =?Utf-8?B?SmVycnk=?= |
last post by:
Hi All,
I want to fill some textbox with properties from Active Directory. The fact
is if the property is unavailable the program will crash. You can prevent
this by using a try and catch. So...
|
by: =?Utf-8?B?U2F2dm91bGlkaXMgSW9yZGFuaXM=?= |
last post by:
Is it right when placing the RETURN statement inside the TRY or inside the
CATCH statement, when there is a FINALLY clause? Especially when there is a
transaction going on, in the try/catch block?...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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...
|
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...
|
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
|
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...
|
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,...
|
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...
| |