# Re: VB中的串口通&#35759;&#38382;&#39064;

Posted by 尧仔 on December 12, 1998 at 23:58:15:

In Reply to: VB中的串口通讯问题 posted by Tracy on December 09, 1998 at 11:41:38:

Private Sub Form_Load ()
' 储存输入字串的暂存区
Dim Instring As String
' 使用 COM1.
MSComm1.CommPort = 1
' 连线速度 9600 baud、无同位检查、资料位元 8、停止位元 1
MSComm1.Settings = "9600,N,8,1"
' 告诉控制项当使用 Input 时，读取整个暂存区
MSComm1.InputLen = 0
' 开启连接埠
MSComm1.PortOpen = True
' 将 attention 指令送到数据机
MSComm1.Output = "AT" + Chr$(13)
' 等待资料传回到连接埠
Do
DoEvents
Loop Until MSComm1.InBufferCount >= 2
' 从连接埠读取 "OK" 回应资料
Instring = MSComm1.Input
' 关闭连接埠
MSComm1.PortOpen = False
End

Follow Ups: