Now i need to pass the value in a string (which represents a Hexadecimal value) to a UInt32 variable.
I´m asking the user to insert a distance in the application, and then i´m converting the value to Hexadecimal, then splitting the value, and then adding the 0x to the hexa values. Now i need to put the values into the UInt32[] cmd_data to send to the machine, but i´m having difficulties doing this.
I have this so far:
Code: Select all
UInt32 uiDecimal = 0;
int s = 21;
Convert.ToUInt32(s);
try
{
// Convert text string to unsigned integer
uiDecimal = checked((UInt32)System.Convert.ToUInt32(this.textBoxNum.Text));
}
catch (System.OverflowException exception)
{
}
string var = String.Format("{0:x}", uiDecimal);
string[] idUser1 = new string[3];
idUser1[0] = var.Remove(1);
idUser1[1] = var.Substring(1);
string num1 = "0x" + idUser1[0].ToString();
string num2 = "0x" + idUser1[1].ToString();
Rui