|
我在vs2003下用vb.net开发了一个简单程序可在wince4.2上面正常运行,但这个程序用在wince5.0下运行,可以启动界面,但点按钮执行功能时没有效果。然后我又把同样的程序用vs2005找开重新编译,但是编译好的程序放在wince5下运行时,什么反应都没有,连界面(仅是一个铵钮和一个文本框)都没有出现,这是为什么?CE5能不能运行VS2005开发的程序?或能不能运行vs2003开发的程序:
我的程序代码很简单,就是把输入的字符转成16进制发送出去,vs2003下编译的在CE4.2下测试通过,但我要的是ce5也能通过,怎么办,以下是我的部份核心代码:
Strs = ""
Dim Tstr As String
For X = 1 To Len(txtMessage.Text)
Tstr = Mid(txtMessage.Text, X, 1)
If Tstr = "'" Or Tstr = "[" Or Tstr = "]" Then
MsgBox("不允许输入如下的非法字符:'或[或]")
Exit Sub
End If
If Asc(Tstr) >= 48 And Asc(Tstr) <= 57 Then '数字
Strs = Strs & "," & Tstr
Else
If Asc(Tstr) >= 97 And Asc(Tstr) <= 122 Then '小写字母
L = InStr(1, ChrL, Tstr)
Strs = Strs & "," & Hex(10 + L)
Else
If Asc(Tstr) >= 65 And Asc(Tstr) <= 90 Then '大写字母
L = InStr(1, Chr, Tstr)
Strs = Strs & "," & Hex(36 + L)
Else
If InStr(1, ChrD, Tstr) > 0 Then
L = InStr(1, ChrD, Tstr)
Strs = Strs & "," & Hex(62 + L)
Else
If InStr(1, ChrE, Tstr) > 0 Then
L = InStr(1, ChrE, Tstr)
Strs = Strs & "," & Hex(73 + L)
Else
If Asc(Tstr) = 32 Then Strs = Strs & "," & "0A"
If Asc(Tstr) = 34 Then Strs = Strs & "," & "49"
End If
End If
End If
End If
End If
Next
Console.WriteLine(Strs)
End If
m_cs232.openPort() '打开串口
Dim Ar() As String
Ar = Split(Strs, ",")
ReDim Buf(UBound(Ar) + 3)
Buf(0) = &H40
Buf(1) = &H11
For X = 2 To Ar.Length
Buf(X) = "&H" & Ar(X - 1)
If Oct(Buf(X)) = 12 Then
Buf(X) = &HA
End If
Next
Buf(X) = &HFF
m_cs232.write(Buf) '发送
Console.WriteLine(Buf(X))
m_cs232.closePort() '关闭串口
|
|