Saturday, March 24, 2012

Operator is not Valid

Integer conversion can be done with cint(variable) or
system.convert.ToInt32(variable) or bitconverter.ToInt32(variable).
An integer (if you are using 'dim i as integer') is the equivalent of
a 32-bit signed integer.

Don Krapohl
http://www.tranquillitas.com
Website quality assurance testingThank you for your help, but now I'm getting this message:

"System.InvalidCastException: Cast from type 'UInt16' to type 'Integer' is
not valid."

I tried using cint(entry("LoadPercentage")). None of the other conversion
methods you listed seem to work. I'm using VB, not C. I don't know if that
makes a difference.

I apologize. I've gotten lazy by using Perl too much. I haven't had to
declare types in a few years and I'm a bit rusty. I'm totally new to the
way .NET does it.

I appreciate your help.

-Kevin
Integers in .Net are of the type Int32.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
The more I learn, the less I know.

"Kevin Vaughn" <kevin.vaughn@.ttu.edu> wrote in message
news:vks1bljq51edd5@.corp.supernews.com...
> Thank you for your help, but now I'm getting this message:
> "System.InvalidCastException: Cast from type 'UInt16' to type 'Integer' is
> not valid."
> I tried using cint(entry("LoadPercentage")). None of the other conversion
> methods you listed seem to work. I'm using VB, not C. I don't know if
that
> makes a difference.
> I apologize. I've gotten lazy by using Perl too much. I haven't had to
> declare types in a few years and I'm a bit rusty. I'm totally new to the
> way .NET does it.
> I appreciate your help.
> -Kevin
Dim shtOriginal As Int16 = 4
Dim intConverted As Integer
intConverted = System.Convert.ToInt32(shtOriginal)

This is VB.NET source for the conversion. It worked fine for me. Let
me know if you are still having problems.

Don Krapohl
http://www.tranquillitas.com
Website quality control testing

0 comments:

Post a Comment