如何将十六进制转换为小数 [英] how to convert hexadecimal to decimal vaule
本文介绍了如何将十六进制转换为小数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
朋友我正在使用以下代码
Hey Friend I am Using the following code
Dim lstrRevHex As String = Strings.StrReverse(lStrHex)
Dim LLngRetValue As Long
For temp As Integer = 0 To lstrRevHex.Length - 1
LLngRetValue += Val(lstrRevHex(temp)) * Math.Pow(16, temp)
Next
在NUMERIC形式但为十六进制值的情况下有效,但在值为ALFA NUMERICE形式的情况下不起作用
请确实需要ful
it work when hexadecimal value in NUMERIC Form BUT it not work when value is ALFA NUMERICE form
plss do need ful
推荐答案
阅读以下内容: ^ ]
Read the following : http://stackoverflow.com/questions/642417/how-do-you-convert-hex-to-decimal-using-vb-net[^]
您可以添加这样的字典:
You can add a dictionary like that:
Dim lStrHex As String = "1A"
Dim numbers As New Dictionary(Of String, Integer) From {{"0", 0}, {"1", 1}, {"2", 2}, {"3", 3}, {"4", 4}, {"5", 5}, {"6", 6}, {"7", 7}, {"8", 8}, {"9", 9}, {"A", 10}, {"B", 11}, {"C", 12}, {"D", 13}, {"E", 14}, {"F", 15}}
Dim lstrRevHex As String = Strings.StrReverse(lStrHex)
Dim LLngRetValue As Long
For temp As Integer = 0 To lstrRevHex.Length - 1
LLngRetValue += numbers(lstrRevHex(temp)) * Math.Pow(16, temp)
Next
MessageBox.Show(LLngRetValue)
这篇关于如何将十六进制转换为小数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文