VBS如何把字符串转换为16进制数值?
例如:把字符串"100ABC"转换为16进制数值,然后可以加1变为100ABD,加4自动进位变为100AC0注:是VBS不是vb...
例如:把字符串"100ABC"转换为16进制数值,然后可以加1变为100ABD,加4自动进位变为100AC0
注:是VBS不是vb 展开
注:是VBS不是vb 展开
展开全部
Public Function StrToHex(ByVal strS As String) As String
'将字符串转换为16进制
Dim abytS() As Byte
Dim bytTemp As Byte
Dim strTemp As String
Dim lLocation As Long
abytS = StrConv(strS, vbFromUnicode)
For lLocation = 0 To UBound(abytS)
bytTemp = abytS(lLocation)
strTemp = Hex(bytTemp)
strTemp = Right("00" & strTemp, 2)
StrToHex = StrToHex & strTemp
Next lLocation
StrToHex = StrToHex
End Function
Public Function HexToStr(str As String) As String
'将16进制转换为字符串
Dim rst() As Byte
Dim i As Long, j As Long, strlong As Long
strlong = Len(str)
ReDim rst(strlong \ 2)
For i = 0 To strlong - 1 Step 2
Dim tmp As Long
rst(i / 2) = Val("&H" & Mid(str, i + 1, 2))
Next
HexToStr = StrConv(rst, vbUnicode)
End Function
'将字符串转换为16进制
Dim abytS() As Byte
Dim bytTemp As Byte
Dim strTemp As String
Dim lLocation As Long
abytS = StrConv(strS, vbFromUnicode)
For lLocation = 0 To UBound(abytS)
bytTemp = abytS(lLocation)
strTemp = Hex(bytTemp)
strTemp = Right("00" & strTemp, 2)
StrToHex = StrToHex & strTemp
Next lLocation
StrToHex = StrToHex
End Function
Public Function HexToStr(str As String) As String
'将16进制转换为字符串
Dim rst() As Byte
Dim i As Long, j As Long, strlong As Long
strlong = Len(str)
ReDim rst(strlong \ 2)
For i = 0 To strlong - 1 Step 2
Dim tmp As Long
rst(i / 2) = Val("&H" & Mid(str, i + 1, 2))
Next
HexToStr = StrConv(rst, vbUnicode)
End Function
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询