Determine if decimal value too large

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Guest's Avatar

    #1

    Determine if decimal value too large

    How can I determine if a value the user entered is too large for a decimal
    datatype?

    for instance, if the user enters 123456789012345 67890123456789

    and my variable
    Dim inches as Decimal = cDec(textbox1.t ext)

    Causes an exception. How can I capture this before it causes an exception.


  • Alexey Smirnov

    #2
    Re: Determine if decimal value too large

    On Sep 30, 11:15 pm, <testerwrote:
    How can I determine if a value the user entered is too large for a decimal
    datatype?
    >
    for instance, if the user enters 123456789012345 67890123456789
    >
    and my variable
        Dim inches as Decimal = cDec(textbox1.t ext)
    >
    Causes an exception.  How can I capture this before it causes an exception.
    Use Try..Catch block

    Try
    Dim inches As Decimal = CDec(x)
    ....
    Catch
    End Try

    Comment

    Working...