怎样实现timer1.Enabled = True 运行15秒后,timer1.Enabled = F timer2.Enabled = T
PrivateSubForm_Load()Comm1.Settings="2400,N,8,1"'设置通信口参数Comm1.InBufferSize=150'设置Comm...
Private Sub Form_Load()
Comm1.Settings = "2400,N,8,1" '设置通信口参数
Comm1.InBufferSize = 150 '设置Comm1接收缓冲区为150字节
Comm1.OutBufferSize = 2 '设置Comm1发送缓冲区为2字节
Comm1.InputMode = comInputModeBinary '设置接收数据模式为二进制形式
Comm1.InBufferCount = 0 '清除接收缓冲区
Comm1.OutBufferCount = 0 '清除发送缓冲区
Comm1.RThreshold = 15 '设置接收15个字节产生OnComm事件
Comm1.CommPort = 1
Comm1.InputLen = 15 '设置由串型端口读入的字符长度
Comm1.PortOpen = True '打开通信口
Timer1.Enabled = False
Timer2.Enabled = False
End Sub
Private Sub Txtinput_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Len(Txtinput.Text) = 1 Then
Txtinput.Text = ""
Timer1.Enabled = True
'Timer2.Enabled = True
Else:
MsgBox "序列号的长度不正确", vbCritical
End If
End If
End Sub
Private Sub Timer1_Timer()
Call Inputdata
Call Drawline
End Sub
Private Sub timer2_timer()
Call Inputdata
Call Drawline2
End Sub
Private Sub Inputdata()
LenOfText = Len(txtSum.Text) \ 2 - 1
ReDim OutBuffer(LenOfText)
If Comm1.PortOpen = False Then
Comm1.PortOpen = True
End If
q = 0
For e = 1 To Len(txtSum.Text) Step 2
tem = Mid(txtSum.Text, e, 2)
OutBuffer(q) = Val("&H" & tem)
Debug.Print Val("&H" & tem)
q = q + 1
Next
Comm1.Output = OutBuffer
End Sub
Private Sub Drawline()
Dim y As Double
Static i As Integer
y = Val(Text3.Text)
OPCPic.DrawWidth = 5
OPCPic.PSet (OPCPic.ScaleWidth / 200 * i, OPCPic.ScaleHeight - y)
i = i + 1
Bollth = True
End Sub
Private Sub Drawline2()
Dim y As Double
Static i As Integer
y = Val(Text3.Text)
SLEEVEPic.DrawWidth = 5
SLEEVEPic.PSet (SLEEVEPic.ScaleWidth / 200 * i, SLEEVEPic.ScaleHeight - y)
i = i + 1
End Sub 展开
Comm1.Settings = "2400,N,8,1" '设置通信口参数
Comm1.InBufferSize = 150 '设置Comm1接收缓冲区为150字节
Comm1.OutBufferSize = 2 '设置Comm1发送缓冲区为2字节
Comm1.InputMode = comInputModeBinary '设置接收数据模式为二进制形式
Comm1.InBufferCount = 0 '清除接收缓冲区
Comm1.OutBufferCount = 0 '清除发送缓冲区
Comm1.RThreshold = 15 '设置接收15个字节产生OnComm事件
Comm1.CommPort = 1
Comm1.InputLen = 15 '设置由串型端口读入的字符长度
Comm1.PortOpen = True '打开通信口
Timer1.Enabled = False
Timer2.Enabled = False
End Sub
Private Sub Txtinput_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Len(Txtinput.Text) = 1 Then
Txtinput.Text = ""
Timer1.Enabled = True
'Timer2.Enabled = True
Else:
MsgBox "序列号的长度不正确", vbCritical
End If
End If
End Sub
Private Sub Timer1_Timer()
Call Inputdata
Call Drawline
End Sub
Private Sub timer2_timer()
Call Inputdata
Call Drawline2
End Sub
Private Sub Inputdata()
LenOfText = Len(txtSum.Text) \ 2 - 1
ReDim OutBuffer(LenOfText)
If Comm1.PortOpen = False Then
Comm1.PortOpen = True
End If
q = 0
For e = 1 To Len(txtSum.Text) Step 2
tem = Mid(txtSum.Text, e, 2)
OutBuffer(q) = Val("&H" & tem)
Debug.Print Val("&H" & tem)
q = q + 1
Next
Comm1.Output = OutBuffer
End Sub
Private Sub Drawline()
Dim y As Double
Static i As Integer
y = Val(Text3.Text)
OPCPic.DrawWidth = 5
OPCPic.PSet (OPCPic.ScaleWidth / 200 * i, OPCPic.ScaleHeight - y)
i = i + 1
Bollth = True
End Sub
Private Sub Drawline2()
Dim y As Double
Static i As Integer
y = Val(Text3.Text)
SLEEVEPic.DrawWidth = 5
SLEEVEPic.PSet (SLEEVEPic.ScaleWidth / 200 * i, SLEEVEPic.ScaleHeight - y)
i = i + 1
End Sub 展开
若以下回答无法解决问题,邀请你更新回答
2个回答
展开全部
Private Sub Timer1_Timer()
Static i As Long
i = i + 1
If i > 15 * 1000 / Timer1.Interval Then Timer1.Enabled = False: Timer2.Enabled = True
Call Inputdata
Call Drawline
End Sub
Static i As Long
i = i + 1
If i > 15 * 1000 / Timer1.Interval Then Timer1.Enabled = False: Timer2.Enabled = True
Call Inputdata
Call Drawline
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
代码太长太乱,没耐心看下去 直接说明 你需要实现什么效果
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询