Private Sub Command2_Click()
MSComm1.Output = Trim(Chr(35) + Chr(77) + Chr(82) + Chr(119) + Chr(84) + Chr(13) + Chr(10))
End Sub
Private Sub Command3_Click()
MSComm1.Output = Trim(Chr(35) + Chr(77) + Chr(82) + Chr(119) + Chr(70) + Chr(13) + Chr(10))
End Sub
Private Sub Form_Load()
MSComm1.CommPort = 1
MSComm1.Settings = "19200,n,8,1"
MSComm1.InputMode = 0
MSComm1.PortOpen = True
End Sub
Private Sub Timer1_Timer()
Dim buf$
buf = Trim(MSComm1.Input)
If Len(buf) <> 0 Then
Text2.Text = buf
End If
End Sub
这个程序在VB中能正常使用,不过放在IFIX的脚本里就运行出错,点击按钮时内存溢出,有没有使用过的。
Private Sub Form_Load()
MSComm1.CommPort = 1
MSComm1.Settings = "19200,n,8,1"
MSComm1.InputMode = 0
MSComm1.PortOpen = True
End Sub
你上面这个函数最好放在周期触发脚本里头执行,最好加上判断语句。
Private Sub Form_Load()
if MSComm1.PortOpen = fasle then
MSComm1.CommPort = 1
MSComm1.Settings = "19200,n,8,1"
MSComm1.InputMode = 0
MSComm1.PortOpen = True
end if
End Sub