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發送請求