光伏产业epc总包怎么样:vb.net的怪异问题...

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/29 18:47:55
我想写个ascii转chr的函数,输入的ascii值每两个之间是用空个间隔。运行在Windows Mobile 5.0上面。语言为vb 2005。
函数如下
Function ASCII2Char(ByVal inputdata)
Dim L As Integer = Len(inputdata)
Dim Data As String = inputdata
Dim i As Integer
Dim Temp As String
Dim Result As String
For i = 1 To L
If Mid(Data, i, 1) <> " " And i <> L Then
Temp = Temp & Mid(Data, i, 1)
Else
'MsgBox(Temp)
Result = Result & " " & Chr(Temp)
Temp = ""
End If
Next
ASCII2Char = Result
End Function
现在出现了个怪异问题,如果加上那个msgbox(temp),程序就完全正常,否则最后一个字符输出的时候就是一个小方块...msgbox(temp)不会改变temp的值啊,为什么结果就是不一样呢?大家能不能给我个解决方案,让程序正常,谢谢。
另外,编写wm5.0应用程序的时候,没有debug.print()用,请问用什么方法代替呢?

我试了,好象输入的字符必须数字,我改了一下你试试看吧.
Function ASCII2Char(ByVal inputdata)
Dim L As Integer = Len(inputdata)
Dim Data As String = inputdata
Dim i As Integer
Dim Temp As String
Dim Result As String
L = L + 1 '因为下面的循环 是从1到L-1的(为L时不取字符)
For i = 1 To L
If Mid(Data, i, 1) <> " " And i <> L Then
Temp = Temp & Mid(Data, i, 1)
Else
'MsgBox(Temp)
If IsNumeric(Temp) Then
Result = Result & " " & Chr(Temp)
Else
MsgBox("输入的不是数字: " & Temp)
End If
Temp = ""
End If
Next
ASCII2Char = Result
End Function