none
help int get textbox RRS feed

  • Question

  • how get vaule 0x48B97936 from textbox to int

    i use the code but not work

    int value = Convert.ToInt32(textBox1.Text);
    error Additional information: Input string was not in a correct format.

    and

    int value = int.Parse(textBox1.Text);

    error Additional information: Input string was not in a correct format.


    Friday, September 13, 2019 12:10 PM

Answers

  • Reemove "0x" from begin:

    int value = int.Parse(textBox1.Text.Remove(0, 2), System.Globalization.NumberStyles.HexNumber);

    no i want get vule not want remove anything

    If you remove "0x", it will convert the hex number to int...

    or 

     int value = Convert.ToInt32(textBox1.Text, 16);

    • Edited by Castorix31 Friday, September 13, 2019 12:52 PM
    • Marked as answer by programmervb.net Friday, September 13, 2019 1:00 PM
    Friday, September 13, 2019 12:49 PM

All replies

  • Reemove "0x" from begin:

    int value = int.Parse(textBox1.Text.Remove(0, 2), System.Globalization.NumberStyles.HexNumber);

    • Proposed as answer by Castorix31 Friday, September 13, 2019 12:49 PM
    Friday, September 13, 2019 12:31 PM
  • Reemove "0x" from begin:

    int value = int.Parse(textBox1.Text.Remove(0, 2), System.Globalization.NumberStyles.HexNumber);

    no i want get vule not want remove anything
    Friday, September 13, 2019 12:39 PM
  • Reemove "0x" from begin:

    int value = int.Parse(textBox1.Text.Remove(0, 2), System.Globalization.NumberStyles.HexNumber);

    no i want get vule not want remove anything

    If you remove "0x", it will convert the hex number to int...

    or 

     int value = Convert.ToInt32(textBox1.Text, 16);

    • Edited by Castorix31 Friday, September 13, 2019 12:52 PM
    • Marked as answer by programmervb.net Friday, September 13, 2019 1:00 PM
    Friday, September 13, 2019 12:49 PM