你的字符串好像没逻辑意义把 "不允许访问" (x表示16 进制数) Copy 到 Html 中用 IE 显示 "不允许访问"Private Sub Command1_Click() 'x 表示 16 进制,无 x 为十进制数 vba.MsgBox DecodeString("不允许访问") End Sub Public Function DecodeString(StringX As String) As String Dim a() As String a = VBA.Split(StringX, ";") Dim sByte(1) As Byte For i = LBound(a) To UBound(a) If VBA.Len(VBA.Trim(a(i))) > 0 Then If VBA.InStr(a(i), "x") > 0 Then a(i) = VBA.Replace(a(i), "&#x", "") Else a(i) = VBA.Hex(VBA.Replace(a(i), "&#", "")) End If sByte(0) = "&H" & VBA.Right(a(i), 2) sByte(1) = "&H" & VBA.Left(a(i), VBA.Len(VBA.Trim(a(i))) - 2) DecodeString = DecodeString & VBA.StrConv(sByte, vbNarrow) End If Next i End Function
这些是 unicode 的字符,在 datagrid 上应该是可以显示的,因为 datagrid 是 unicode-enabled 的。下面的一段话是从 MSDN 中关于 DataGrid control 的帮助中拷贝出来的。Note This control is Unicode-enabled. When used on a Unicode-enabled system such as Microsoft Windows NT, the control passes Unicode data with no conversion. On other systems, however, data is converted from ANSI to Unicode and back. For more information, see "ANSI, DBCS, and Unicode: Definitions" in the Programmer's Guide.
"不允许访问" (x表示16 进制数)
Copy 到 Html 中用 IE 显示
"不允许访问"Private Sub Command1_Click()
'x 表示 16 进制,无 x 为十进制数
vba.MsgBox DecodeString("不允许访问")
End Sub
Public Function DecodeString(StringX As String) As String
Dim a() As String
a = VBA.Split(StringX, ";")
Dim sByte(1) As Byte
For i = LBound(a) To UBound(a)
If VBA.Len(VBA.Trim(a(i))) > 0 Then
If VBA.InStr(a(i), "x") > 0 Then
a(i) = VBA.Replace(a(i), "&#x", "")
Else
a(i) = VBA.Hex(VBA.Replace(a(i), "&#", ""))
End If
sByte(0) = "&H" & VBA.Right(a(i), 2)
sByte(1) = "&H" & VBA.Left(a(i), VBA.Len(VBA.Trim(a(i))) - 2)
DecodeString = DecodeString & VBA.StrConv(sByte, vbNarrow)
End If
Next i
End Function
我要显示带“^”的字母:即^C 应在同一位置,即C上有“^”。或者 C 下面有“ ,”
这个坛子太差劲,无法显示!!
你可用:Form20.dll 中的textbox 显示一下 Chr(264),Chr(265)
你就会知道这是什么。
关键是如何在数据网格中显示!