Specifications
5 - 17
5.4 Visual Basic Program (Device Read)
The contents of ON/OFF status for PLC CPU bit device X0 to X7 (eight points) and of
word device D0 to D4 (five words) are read.
5.4.1 Visual basic program
Project file name
E71-1.VBP
Option Explicit ’Force the declaration of variables
Const MonitorTime As Integer = 100 'Device monitor interval
Private Sub cmdOpen_Click()
Dim lRet As Long 'Return value
lRet = ActEasyIF1.Open 'Open the communication line
If lRet = 0 Then
txtStatus.Text = _
"Communication line was opened normally. " 'Message at normal
cmdOpen.Enabled = False 'Disable the Open button
cmdClose.Enabled = True 'Enable the Close button
cmdMonitor.Enabled = True 'Enable the Monitor start button
cmdEnd.Enabled = False 'Disable the End button
Else
txtStatus.Text = _
"Error occurrence (Error code: " + Hex$(lRet) + ")" 'Message at abnormal
End If
End Sub
Private Sub cmdClose_Click()
Dim lRet As Long 'Return value
lRet = ActEasyIF1.Close 'Close the communication line
If lRet = 0 Then
txtStatus.Text = _
"Communication line was closed normally. " 'Message at normal
cmdOpen.Enabled = True 'Enable the Open button
cmdClose.Enabled = False 'Disable the Close button
cmdMonitor.Enabled = False 'Disable the Monitor start button
cmdEnd.Enabled = True 'Enable the End button
Else
txtStatus.Text = _
"Error occurrence (Error code: " + Hex$(lRet) + ")" 'Message at abnormal
End If
End Sub