Specifications

5 - 29
5.5 Visual Basic Program (Device Write)
The contents of PLC CPU bit device Y70 to Y77 (eight points) and of word device D0
to D4 (five words) are changed.
5.5.1 Visual basic program
Project file name
E71-2.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 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