十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
numHex =Integer.Parse(strHex, Globalization.NumberStyles.AllowHexSpecifier)
创新互联公司专注于企业成都全网营销推广、网站重做改版、东至网站定制设计、自适应品牌网站建设、H5场景定制、购物商城网站建设、集团公司官网建设、成都外贸网站建设、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为东至等各大城市提供网站开发制作服务。
或
numHex = Integer. Parse("H" strHex)
10进制转16进制的话可以使用HEX()函数,16进制转10进制没有现成函数,可以使用如下代码实现:
' 用途:将十六进制转化为十进制
' 输入:Hex(十六进制数)
' 输入数据类型:String
' 输出:HEX_to_DEC(十进制数)
' 输出数据类型:Long
' 输入的最大数为7FFFFFFF,输出的最大数为2147483647
Public Function HEX_to_DEC(ByVal Hex As String) As Long
Dim i As Long
Dim B As Long
Hex = UCase(Hex)
For i = 1 To Len(Hex)
Select Case Mid(Hex, Len(Hex) - i + 1, 1)
Case "0": B = B + 16 ^ (i - 1) * 0
Case "1": B = B + 16 ^ (i - 1) * 1
Case "2": B = B + 16 ^ (i - 1) * 2
Case "3": B = B + 16 ^ (i - 1) * 3
Case "4": B = B + 16 ^ (i - 1) * 4
Case "5": B = B + 16 ^ (i - 1) * 5
Case "6": B = B + 16 ^ (i - 1) * 6
Case "7": B = B + 16 ^ (i - 1) * 7
Case "8": B = B + 16 ^ (i - 1) * 8
Case "9": B = B + 16 ^ (i - 1) * 9
Case "A": B = B + 16 ^ (i - 1) * 10
Case "B": B = B + 16 ^ (i - 1) * 11
Case "C": B = B + 16 ^ (i - 1) * 12
Case "D": B = B + 16 ^ (i - 1) * 13
Case "E": B = B + 16 ^ (i - 1) * 14
Case "F": B = B + 16 ^ (i - 1) * 15
End Select
Next i
HEX_to_DEC = B
End Function
扩展资料:
在VB中将十进制转化为十六进制的函数:
输入:Dec(十进制数)'
输入数据类型:Long'
输出:D2H(十六进制数)'
输出数据类型:String'
输入的最大数为2147483647,
输出最大数为7FFFFFFFPublicFunction D2H(Dec As Long) As String
Dim a As String
D2H = ""
Do While Dec 0
a = CStr(Dec Mod 16) Select Case a Case "10": a = "A"
Case "11": a = "B"
Case "12": a = "C"
Case "13": a = "D"
Case "14": a = "E"
Case "15": a = "F"
End Select
D2H = a D2H
Dec = Dec \ 16 LoopEnd Function
'此函数用于十进制到二进制
Private Function Bin(Number As Long) As Long
Dim Div_value As String
Do
Div_value = (Number Mod 2) Div_value
Number = Int(Number / 2)
Loop Until Number 2
Bin = Number Div_value
End Function
'此函数用于二进制到十进制
Private Function value_Bin(Number As Long) As Long
Dim Temp_value As Long, Cyc As Long
For Cyc = 0 To Len(Str(Number))
If Cyc = Len(Str(Number)) Then
value_Bin = Temp_value + Val(Mid(Str(Number), Cyc, 1))
Exit For
End If
If Cyc 0 Then Temp_value = (Temp_value + Val(Mid(Str(Number), Cyc, 1))) * 2
Next Cyc
End Function
'====写入以上函数后转值操作:
'十进制到十六进制:Hex(十进制数值)
'十进制到八进制:Oct(十进制数值)
'十进制到二进制:Bin(十进制数值)
'二进制到十进制:value_Bin(二进制数值)
'八进制到十进制:Val("O" 八进制数值)
'十六进制到十进制:Val("H" 十六进制数值)
比如
msgbox DEC_to_BIN(10)
就会返回一个10转换为十进制后的结果
或者简单点就用
VB自带函数:
十进制转八进制:Oct(num)
十六进制转八进制:oct("H" num)
十进制转十六进制:hex(num)
八进制转十六进制:hex("O" num)
十六进制转换为十进制
Dim str As String
str = Text2.Text
Text10.Text = CLng("H" str)
首先引入System.IO命名空间
Imports System.IO
然后使用文件流来读入数组:
Dim bytes() As Byte
Using fs As New FileStream(文件路径,FileMode.Open)
ReDim bytes(fs.Length-1)
fs.Read(bytes,0,fs.Length)
fs.Close()
End Using
这样bytes就是整个文件的所有字节了
从字节生成Image:
Dim img As Image = Image.FromStream(New MemoryStream(bytes))
img就是图片了