How do you convert hex to decimal using VB.NET?

后端 未结 9 1800
自闭症患者
自闭症患者 2020-12-11 03:04

I need to convert hex to a decimal in VB.NET. Found several examples in C#, but when I tried to convert to VB.NET I was not successful. An example of a hexadecimal number th

9条回答
  •  萌比男神i
    2020-12-11 03:29

    Write one yourself.

    You will need to tokenize the string, then start from the right, and work your way left.

    int weight = 1;
    While Looping
    {
    
      If (token(i) == "F") { DecimalValue += 15 * weight; }
      If (token(i) == "E") { DecimalValue += 14 * weight; }
      If (token(i) == "D") { DecimalValue += 13 * weight; }
      If (token(i) == "C") { DecimalValue += 12 * weight; }
      If (token(i) == "B") { DecimalValue += 11 * weight; }
      If (token(i) == "A") { DecimalValue += 10 * weight; }
      else { DecimalValue += token(i) * weight; }
    
      weight = weight * 16;
    }
    

    Something like that.

提交回复
热议问题