PC机与Agilent34401A万用电表之间如何进行RS-232串口通信啊?
我想实现PC机与34401A电表间的RS-232串口通信,第一次使用VB,不知道怎么写.哪位大侠能给出一段代码的事例参考下啊.急~~~
Private Sub Form_Load()
msc1.CommPort = 1
msc1.Settings = “ 9600 ,N, 8 ,1”
msc1.InputLen = 0
msc1.PortOpen = True
msc1.InputMode = comInputModeText
End Sub
Private Sub Command1_Click()
On Error Resume Next
If Txt1.Text = "" Then
X = MsgBox("被检仪器程控码不能为空值", 16)
Exit Sub
End If
msc1.Output = Txt1.Text + Chr$(13)
For i = 1 To 20000000
Next
End Sub
Private Sub Command2_Click()
Txt1.Text = ""
Txt1.SetFocus
End Sub
Private Sub Command3_Click()
Dim instring As String
instring = msc1.Input
msc1.Output = Txt2.Text + Chr$(13)
Do
DoEvents
Loop Until msc1.InBufferCount >= 20
instring = msc1.Input
Txt2.Text = ""
Txt2.Text = instring
End Sub
Private Sub Command4_Click()
Txt2.Text = ""
Txt2.SetFocus
End Sub
Private Sub Command5_Click()
msc1.PortOpen = False
End
End Sub
编译就出错,msc1.Settings = “ 9600 ,N, 8 ,1”不知道怎么从电表的232串口传输数据到PC机的232串口!
--------------------编程问答-------------------- 不知道通讯协议
补充:VB , 控件