|
 |
access thread: check textbox for integer
Message #1 by "eindre lucynier" <centurion99@h...> on Tue, 26 Mar 2002 05:02:51
|
|
Are there any for checking integer values in text box???
I can't find any...
for textbox validation on loss focus event.
Message #2 by "Phillip Johnson" <phillip.johnson@e...> on Tue, 26 Mar 2002 11:05:15
|
|
Try converting the value in the textbox to an integer with this line of
code:
dim intVariable as integer
intVariable = cInt(txtBox.Value)
If the conversion is successful, the variable will contain a variable,
otherwise a runtime error 13, Type Mismatch will be thrown that can be
trapped.
A decimal value, however will convert to an integer and round up. Because
of this, if you need to know if the value is an integer or a decimal, you
will have to check out the string. Use the instr(expression, ".")
function to get the location, if any, of a decimal point and then examine
the number after the decimal point. If it is greater than zero, the
number is a decimal.
Hope it works,
Regards, Phillip
> Are there any for checking integer values in text box???
I> can't find any...
> for textbox validation on loss focus event.
Message #3 by ProDev <prodevmg@y...> on Tue, 26 Mar 2002 06:12:50 -0800 (PST)
|
|
--0-1824215259-1017151970=:49746
Content-Type: text/plain; charset=us-ascii
Have you tried the IsNumeric function?
eindre lucynier <centurion99@h...> wrote: Are there any for checking integer values in text box???
I can't find any...
for textbox validation on loss focus event.
Lonnie Johnson, ProDev, Builders of MS Access Databases
Let us build your next MS Access database application.
http://www.galaxymall.com/software/PRODEV
Send and Receive payments for free with PayPal: http://www.paypal.com/refer/pal=Y6TYF7YF8E2JG
---------------------------------
Do You Yahoo!?
Yahoo! Movies - coverage of the 74th Academy Awards®
Message #4 by "Ian Ashton" <ian@c...> on Tue, 26 Mar 2002 20:01:12 -0000
|
|
I have always considered that trapping an error as part of routine coding
should be avoided unless it is absolutely necessary. My suggestion would be:
If Not IsNull(txtBox.Value) Then
If IsNumeric(txtBox.Value) Then
If InStr(txtBox.Value, ".") = 0 Then
MsgBox Txt.Value & " is an integer" 'or any other code you
require at this point.
End If
End If
End If
Ian Ashton
-----Original Message-----
From: Phillip Johnson [mailto:phillip.johnson@e...]
Sent: Tuesday, March 26, 2002 11:05 AM
To: Access
Subject: [access] Re: check textbox for integer
Try converting the value in the textbox to an integer with this line of
code:
dim intVariable as integer
intVariable = cInt(txtBox.Value)
If the conversion is successful, the variable will contain a variable,
otherwise a runtime error 13, Type Mismatch will be thrown that can be
trapped.
A decimal value, however will convert to an integer and round up. Because
of this, if you need to know if the value is an integer or a decimal, you
will have to check out the string. Use the instr(expression, ".")
function to get the location, if any, of a decimal point and then examine
the number after the decimal point. If it is greater than zero, the
number is a decimal.
Hope it works,
Regards, Phillip
> Are there any for checking integer values in text box???
I> can't find any...
> for textbox validation on loss focus event.
Message #5 by "Gerald, Rand" <RGerald@u...> on Tue, 26 Mar 2002 14:12:02 -0600
|
|
If you want to make certain that the value of a floating point number
doesn't round up (you only want the integer part of the number, not the
fraction) use the Fix(n) function.
IntVal =3D Fix(234.56)
IntVal will have the value of 234
Rand E Gerald
Database Specialist
Information Services / Operations
Bah=E1'=ED National Office
1233 Central St.
Evanston IL 60201
(xxx) xxx-xxxx
-----Original Message-----
From: Ian Ashton [mailto:ian@c...]
Sent: Tuesday, March 26, 2002 2:01 PM
To: Access
Subject: [access] Re: check textbox for integer
I have always considered that trapping an error as part of routine
coding
should be avoided unless it is absolutely necessary. My suggestion
would be:
If Not IsNull(txtBox.Value) Then
If IsNumeric(txtBox.Value) Then
If InStr(txtBox.Value, ".") =3D 0 Then
MsgBox Txt.Value & " is an integer" 'or any other
code you
require at this point.
End If
End If
End If
Ian Ashton
-----Original Message-----
From: Phillip Johnson [mailto:phillip.johnson@e...]
Sent: Tuesday, March 26, 2002 11:05 AM
To: Access
Subject: [access] Re: check textbox for integer
Try converting the value in the textbox to an integer with this line of
code:
dim intVariable as integer
intVariable =3D cInt(txtBox.Value)
If the conversion is successful, the variable will contain a variable,
otherwise a runtime error 13, Type Mismatch will be thrown that can be
trapped.
A decimal value, however will convert to an integer and round up.
Because
of this, if you need to know if the value is an integer or a decimal,
you
will have to check out the string. Use the instr(expression, ".")
function to get the location, if any, of a decimal point and then
examine
the number after the decimal point. If it is greater than zero, the
number is a decimal.
Hope it works,
Regards, Phillip
> Are there any for checking integer values in text box???
I> can't find any...
> for textbox validation on loss focus event.
|
|
 |