AdvancedHMI Software
General Category => Support Questions => Topic started by: Darrell on January 05, 2015, 10:07:59 PM
-
I put a label on my form and would like it to show the driver address when the form loads and maybe also have it change automatically if I change the driver IP via a button ,
this works ok to show the Ip address , but I have to click on it to show the Ip address
Private Sub BasicLabel18_Click(sender As System.Object, e As System.EventArgs) Handles BasicLabel18.Click
BasicLabel18.Text = EthernetIPforPLCSLCMicroCom1.IPAddress
End Sub
thanks Darrell
-
For Main Form you could use the load event (double click the Main Form and it should show right away):
Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
BasicLabel18.Text = EthernetIPforPLCSLCMicroCom1.IPAddress
End Sub
The way I am thinking, a timer added to the form could work as well and should be updating the label text property for the interval specified (like 1000 or 2000 milliseconds).
Archie might have better answer anyway.
-
I'll show you a little bit of an advanced method that will also give you some insight into .NET component building.
- Open EthernetIPforPLCSLCMicroCom.vb and go to line 55
- Add this line of code to declare a new event:
Public Event IPAddressChanged As EventHandler
- Go to line 191 (just before the End If) and add this line of code:
OnIPAddressChanged
-Go all the way to the bottom just one line before "End Class" and add this code:
Protected Overridable Sub OnIPAddressChanged()
RaiseEvent IPAddressChanged(Me, System.EventArgs.Empty)
End Sub
- Go to Window->Close All Documents (just a safety measure to prevent from crashing Visual Studio)
- Build->Rebuild Solution
The driver will now have a new Event that you can use on your form.
- Select the driver instance on your form
- In the Properties Window, click the lightening bolt
- You should now see IPAddressChanged, double click to get to the code for the event handler
-
Cool , will give it a try
Thanks
-
Version 3.97 is now posted that has this new event as part of the driver.