AdvancedHMI Software
General Category => Open Discussion => Topic started by: billerl on July 20, 2017, 11:56:01 AM
-
First of all, let me thank you for this awesome software package. I am a newbie, so there is probably an easy answer to this, I just don't know it. If I've done something wrong in posting this question, just let me know and I'll know not to do it again. - Thanks
With this code I can change my IP address to whatever I want, and it works fine.[size=78%] [/size]
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
ModbusTCPCom1.IPAddress = TextBox2.Text
End Sub
----------------------------------------------------------------------
But if I read the IP address in from a .txt file, it does not work.
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim search As String
Dim fileReader As String
search = TextBox1.Text
If TextBox1.Text = "" Then
Else
fileName = search
End If
Try
fileReader = My.Computer.FileSystem.ReadAllText("C:\folder\" & fileName & ".txt")
TextBox2.Text = fileReader
[/size]ModbusTCPCom1.IPAddress = TextBox2.Text
Catch
MsgBox("Entry Not Valid")
End Try
End Sub
-------------------------------------------------------------------------------------------------
If I use
PilotLight1.Text = ModbusTCPCom1.IPAddress
it flashes the correct IP address, but also flashes "Com Error -999. No Values Returned from Driver"
Any idea what I'm doing wrong?
-
See if this is what you are trying to do:
http://advancedhmi.com/forum/index.php?topic=1782.msg9875#msg9875
http://advancedhmi.com/documentation/index.php?title=INI_File_Usage
-
That is closer to what I want to do. I'd like to use only one driver and just change the IP address based on a selection made from the form.
So how do I accomplish what I'm essentially doing below (that doesn't work)
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
ModbusTCPCom1.IniFileSection = Driver2
End Sub
-
The INI file is only read once on startup, so changing the information does not trigger it to update. However, you can force it to like this:
ModbusTCPCom1.IniFileSection = Driver2
ModbusTCPCom1.EndInit()
-
That works if I make Driver2 a string "Driver2" and it works perfectly in Debug mode.
When i Publish the project I keep getting an error:
"INI File-Unable to locate PLCConfig.ini"
Should I be defining a path like Application.StartupPath for PLCConfig.ini somewhere?
-
That is yet another reason why I heavily discourage the use of Publish. Instead use this method:
http://advancedhmi.com/forum/index.php?topic=14.msg9616#msg9616
-
Perfect!
Thanks Archie - your help has been greatly appreciated.
PS - I do try to search thru the forum for questions before I make a post, I just don't seem to be searching the correct subjects.