为什么我在vb中用mscomm做的串口通信,做的聊天框形式的,为什么一个能换行,而另一个不能呢,求大神指点
就是这样了,两个里面的代码都是一样的呀。代码敬上PrivateSubCommand1_Click()UnloadMeEndSubPrivateSubCommand3_Cl...
就是这样了,两个里面的代码都是一样的呀。代码敬上
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Command3_Click()
Dim st$
st = MSComm1.Input
If Len(st) <> 0 Then
Text1.Text = st & Text1.Text
End If
End Sub
Private Sub Command4_Click()
Text1.Text = ""
End Sub
Private Sub Form_Load()
Timer1.Enabled = True
Text2.TabIndex = 0
Text2.MaxLength = 0
MSComm1.CommPort = 5
MSComm1.PortOpen = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
MSComm1.PortOpen = False
End Sub
刚才落下了代码 如下:
Private Sub Text1_Change()
Text1.SelStart = Len(Text1.Text)
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
MSComm1.Output = Text2.Text
Text2.Text = ""
Text2.TabIndex = 0
End If
End Sub
Private Sub Timer1_Timer()
Dim st$
st = MSComm1.Input
If Len(st) <> 0 Then
Text1.Text = Text1.Text & st
End If
End Sub 展开
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Command3_Click()
Dim st$
st = MSComm1.Input
If Len(st) <> 0 Then
Text1.Text = st & Text1.Text
End If
End Sub
Private Sub Command4_Click()
Text1.Text = ""
End Sub
Private Sub Form_Load()
Timer1.Enabled = True
Text2.TabIndex = 0
Text2.MaxLength = 0
MSComm1.CommPort = 5
MSComm1.PortOpen = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
MSComm1.PortOpen = False
End Sub
刚才落下了代码 如下:
Private Sub Text1_Change()
Text1.SelStart = Len(Text1.Text)
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
MSComm1.Output = Text2.Text
Text2.Text = ""
Text2.TabIndex = 0
End If
End Sub
Private Sub Timer1_Timer()
Dim st$
st = MSComm1.Input
If Len(st) <> 0 Then
Text1.Text = Text1.Text & st
End If
End Sub 展开
2个回答
2013-07-31
展开全部
同意 1 楼的
有可能和你窗体里的控银信件属性设置不一致
推荐看书
Visual_Basic与_RS-232_串行通森蠢信锋春轮控制
有可能和你窗体里的控银信件属性设置不一致
推荐看书
Visual_Basic与_RS-232_串行通森蠢信锋春轮控制
追问
恩 谢谢你 是一致的 呀
追答
哦?肯定?
祝你顺利
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询