Determine if decimal value too large

Discussion in 'ASP .Net' started by Guest, Sep 30, 2008.

  1. Guest

    Guest Guest

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

    for instance, if the user enters 12345678901234567890123456789

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

    Causes an exception. How can I capture this before it causes an exception.
     
    Guest, Sep 30, 2008
    #1
    1. Advertising

  2. On Sep 30, 11:15 pm, <tester> wrote:
    > How can I determine if a value the user entered is too large for a decimal
    > datatype?
    >
    > for instance, if the user enters 12345678901234567890123456789
    >
    > and my variable
    >     Dim inches as Decimal = cDec(textbox1.text)
    >
    > 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
     
    Alexey Smirnov, Sep 30, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Luigi Donatello Asero

    Are these pictures too dark or/and too large?

    Luigi Donatello Asero, May 19, 2004, in forum: HTML
    Replies:
    13
    Views:
    934
    Mabden
    May 21, 2004
  2. Luigi Donatello Asero

    Re: Are these pictures too dark or/and too large?

    Luigi Donatello Asero, May 21, 2004, in forum: HTML
    Replies:
    0
    Views:
    666
    Luigi Donatello Asero
    May 21, 2004
  3. kerravon

    decimal constant too large

    kerravon, Nov 10, 2007, in forum: C Programming
    Replies:
    26
    Views:
    1,304
    Charlie Gordon
    Nov 12, 2007
  4. Dag Sunde
    Replies:
    4
    Views:
    376
  5. shin82

    problem with constant too too large

    shin82, Oct 31, 2012, in forum: C Programming
    Replies:
    0
    Views:
    375
    shin82
    Oct 31, 2012
Loading...

Share This Page