Make a TextBox read a binary number. W#

0

Hello,

I'm doing a program that simulates a ULA (programmable logic unit), and I need my textbox to read the value written in binary.

For example: In TextBox1 the user would type 1010 (number 10 in decimal).

I need this value to be understood as binary. I already can convert from binary to decimal and vice versa, but what I really need is that the textBox already read the number that will be put inside it by the user as binary.

Thanks for the help.

    
asked by anonymous 02.04.2016 / 20:48

1 answer

2

The text that is placed in your TextBox can be converted like this:

int val = Convert.ToInt32(textBox.Text, 2);

This class Convert converts to various numeric bases . The link has other examples.

    
03.04.2016 / 01:02