我用超级终端读取仪器过的数据正常,但用VB写的程序却读取的是乱码?请大家帮帮忙啦,我星期一要交差啊。
With MSComm1
If .PortOpen = False Then
.Settings = "4800,N,8,1"
.CommPort = iPort
.InputLen = 0
Timer2.Interval = ChkTime
.InputMode = comInputModeText
Timer2.Enabled = True
.PortOpen = True
End If
End With
并在timer2事件中读取com口中的内容,显示在文本框中(显示为乱码),请问应该怎么写才对啊
With MSComm1
If .PortOpen = False Then
.Settings = "4800,N,8,1"
.CommPort = iPort
.InputLen = 0
Timer2.Interval = ChkTime
.InputMode = comInputModeText
Timer2.Enabled = True
.PortOpen = True
End If
End With
并在timer2事件中读取com口中的内容,显示在文本框中(显示为乱码),请问应该怎么写才对啊
现在在使用中,没有任何问题。
Public Function M_DuBang(mscomm1 As MSComm) As String
Dim p_input As String
Dim p_num(7) As String
Dim P_Number As String
Dim p_pathf As String
Dim a As Integer
On Error GoTo ine
'Text1.SetFocus
'Do
'Text1.Text = ""
With mscomm1
.CommPort = 1
.Settings = "1200,n,8,1"
.PortOpen = True
End With
Do
Loop While mscomm1.InBufferCount < 21
If mscomm1.InBufferCount >= 20 Then
p_input = ""
p_input = mscomm1.Input
'你的数据读取。
End If
GoTo inerr
ine:
MsgBox Err.Description, , "错误信息"
inerr:
mscomm1.PortOpen = False
'Loop While stops = True
End Function