asc扩展字符写入字符串的问题,急!
dim strinput as string
strinput="9876"
如何将strinput转换成对应的Asc码,然后写入文件,要求 9876 对应的十六进制为2694
我用的转换函数如下
Public Function DecToAsc(ByVal strSource As String)
Dim strOut, strtemp As String
If Not IsNumeric(strSource) Then
DecToAsc = ""
Exit Function
End If
strSource = Hex(strSource)
If Len(strSource) < 4 Then
strSource = String(4 - Len(strSource), "0") + strSource
End If
While Len(strSource) > 0
If Len(strSource) = 1 Then
strSource = "0" + strSource
End If
strtemp = Right(strSource, 2)
Dim lngtemp As Integer
lngtemp = Val("&H" & strtemp & "&")
strtemp = Chr(lngtemp)
strOut = strtemp + strOut
If Len(strSource) > 1 Then
strSource = Left(strSource, Len(strSource) - 2)
End If
Wend
DecToAsc = strOut
End Function
转换的结果对应的十六进制数是2600,原因是chr(148)写入后写成了chr(0)
望各位达人能给出一个切实可行的方案!可调试通过的代码必重谢,分不够再加!