Private Function AscToChar(ByVal sAsc As String) As String
Dim iLen As Integer
Dim i As Integer
On Error GoTo err_Trans
AscToChar = ""
iLen = CInt(Len(sAsc) / 2)
For i = 0 To iLen - 1
If CInt("&H" & Mid(sAsc, i * 2 + 1, 2)) < &H20 Then
AscToChar = ""
Exit Function
Else
AscToChar = AscToChar & Chr(CInt("&H" & Mid(sAsc, i * 2 + 1, 2)))
End If
Next i
exit_Trans:
Exit Function
err_Trans:
AscToChar = ""
Resume exit_Trans
End Function
网上有专门的转换工具的,动易代码生成器好像也可以完成这样的转换,不知道能不能正常运行我就不知道了,没有试过!
private string AscToChar(string sAsc)
{
string functionReturnValue = null;
int iLen = 0;
int i = 0;
// ERROR: Not supported in C#: OnErrorStatement
functionReturnValue = "";
iLen = Convert.ToInt32(Strings.Len(sAsc) / 2);
for (i = 0; i <= iLen - 1; i++) {
if (Convert.ToInt32("&H" + Strings.Mid(sAsc, i * 2 + 1, 2)) < 0x20) {
functionReturnValue = "";
return functionReturnValue;
} else {
functionReturnValue = functionReturnValue +
Strings.Chr(Convert.ToInt32("&H" + Strings.Mid(sAsc, i * 2 + 1, 2)));
}
}
exit_Trans:
return functionReturnValue;
err_Trans:
functionReturnValue = "";
// ERROR: Not supported in C#: ResumeStatement
return functionReturnValue;
}