Results 1 to 3 of 3

Thread: Conversion of textbox.text to integer

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Location
    San Diego - California
    Posts
    251

    Conversion of textbox.text to integer

    Simple question from a C# Newbie

    I have a textbox , that has a numerical entry and I want to add, say 10, to the value on display.

    int i ;

    i = (int) txtBox.text + 10; //Is not allowed as the compiler is not sure whether the entry is a number.

    Any help would be appreciated
    Control Data Systems
    www.members.shaw.ca/cdsystems

  2. #2
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724
    Had this problem myself a couple of days back:
    Code:
    // Default the value.
    int i = 0;
    
    try
    {
        i = int.Parse(txtBox.text)
    }
    catch {}
    i += 10

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Location
    San Diego - California
    Posts
    251
    Thanks that is exactly what I wanted.

    How are the bokke doing!
    Control Data Systems
    www.members.shaw.ca/cdsystems

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width