Private Sub Command1_Click() '电机启动
Dim a As Integer
Dim b As Integer
b = 0
a = MsgBox("是否在启动电机时就启动监视功能并进入曲线监控画面", 4, "监控选择")
If a = 6 Then
'曲线监控.Visible = True
If qxstart_flag = False Then
Set 曲线监控.s = CreateObject("Excel.Application")
'曲线监控.s.Visible = True
Set 曲线监控.exwbook = Nothing
Set 曲线监控.exsheet = Nothing
Set 曲线监控.exwbook = 曲线监控.s.workbooks.open("d:/vb98/3-1.xls")
Set 曲线监控.exsheet = 曲线监控.exwbook.Worksheets("sheet1")
qxstart_flag = True
End If
曲线监控.Visible = True
曲线监控.Timer1.Enabled = True
End If
Do While Form1.complish = True
a = 0
Loop
Form1.complish = True
a = Form1.forcem_y("m0", 1)
Do While b < 10000
b = b + 1
Loop
Do While Form1.complish = True
a = 0
Loop
Form1.complish = True
a = Form1.forcem_y("m0", 0)
End Sub
上面是我写的电机启动代码,上升沿置启动指令,下降沿置M8122发送请求