求EXCEL中GBK转汉字函数
本人EXCEL小白,现在有棘手问题,将A列中的GBK编码转换成汉字(字数不定),放到B列中,现需要一个自定义函数,跪求!现在已有汉字转GBK函数,求哪位高人改一下,GBK...
本人EXCEL小白,现在有棘手问题,将A列中的GBK编码转换成汉字(字数不定),放到B列中,现需要一个自定义函数,跪求!
现在已有汉字转GBK函数,求哪位高人改一下,GBK转中文
Function GetGBK(strInput As String) AsString
Dim x() As Byte
Dim i As Integer
x= strInput
x= StrConv(x, vbFromUnicode)
If (UBound(x) - LBound(x) + 1) / Len(strInput) <> 2 Then
GetGBK = "你输入包含非中文字符"
Else
For i = 0 To UBound(x) Step 2
GetGBK = GetGBK & Hex(x(i)) & Hex(x(i + 1)) & " "
Next i
GetGBK = Trim(GetGBK)
End If
End Function 展开
现在已有汉字转GBK函数,求哪位高人改一下,GBK转中文
Function GetGBK(strInput As String) AsString
Dim x() As Byte
Dim i As Integer
x= strInput
x= StrConv(x, vbFromUnicode)
If (UBound(x) - LBound(x) + 1) / Len(strInput) <> 2 Then
GetGBK = "你输入包含非中文字符"
Else
For i = 0 To UBound(x) Step 2
GetGBK = GetGBK & Hex(x(i)) & Hex(x(i + 1)) & " "
Next i
GetGBK = Trim(GetGBK)
End If
End Function 展开
1个回答
展开全部
根据上面的程序进行逆运算,仅供参考。
Function DeGBK(strGBK As String) As String
Dim x() As Byte, BN&, I%
strGBK = Replace(strGBK, " ", "") '去除原程序中在字符之间添加的空格
BN = Len(strGBK) / 2
ReDim x(1 To BN)
For I = 1 To BN
x(I) = Val("&H" & Mid(strGBK, I * 2 - 1, 2))
Next I
DeGBK = StrConv(x, vbUnicode)
End Function
Function DeGBK(strGBK As String) As String
Dim x() As Byte, BN&, I%
strGBK = Replace(strGBK, " ", "") '去除原程序中在字符之间添加的空格
BN = Len(strGBK) / 2
ReDim x(1 To BN)
For I = 1 To BN
x(I) = Val("&H" & Mid(strGBK, I * 2 - 1, 2))
Next I
DeGBK = StrConv(x, vbUnicode)
End Function
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询