<< Click to Display Table of Contents >> Manual > Server Creation Guide > Interface > IPLink-Interface > IPLinkClient Library > IPLinkClient Library Connection Procedure > Step 4: Reading and writing values |
Reading and Writing Values
The "ReadVal" and "WriteVal" methods are called to read and write tags by clicking the buttons.
1.Paste the control.
Paste two buttons and two text boxes into the form. The buttons and text will be used to read and write the tags.
2.Write the code.
The processing for when the form is loaded, when the Read button is pressed, and when the Write button is pressed is written as follows.
Public Class Form1 '----------------------------------- ' Event - FormLoad '-------------------------------------- Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load AxIPLink1.AddTag("U01.F01.T01", True) 'Register tag End Sub '------------------------------------ ' Read Button Click '------------------------------------ Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim vVal As Object = Nothing If Not AxIPLink1.ReadVal("U01.F01.T01", vVal, 1) Then TextBox1.Text = "Error!" Else TextBox1.Text = vVal End If End Sub '----------------------------------- ' Write Button Click '----------------------------------- Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click If Not AxIPLink1.WriteVal("U01.F01.T01", TextBox2.Text) Then TextBox2.Text = "Error!" End If End Sub End Class
3.Run the program.
Press the Start button on
Visual Basic to start the program. If the T01 tag lamp has turned red as shown below, the connection to the tag has been completed. The current value of the tag can be confirmed in the "Current Value" column. Update the value of the T01 tag and press the Read button on the Visual Basic side to confirm that the value can be obtained. Also, update the value from Visual Basic and press the Write button to confirm that the value is passed to the T01 tag.