Ok, new to vb.net and I want to create a basic app that reads the contents of an xml file (this part works) and then enable (make visible) the required number of buttons (already created on the form but set as not visible by default) for each line of the xml file.
The xml file just lists a program name (which would become the button text) and the path to the file (which should be stored as a variable that is used in the button code (handle?)
The idea is that I have an app that once created, I just update the xml file with new drivers or programs that I want to install or run without having to rebuild the application.
As you would see the line "button_x.Text = NameValue" is not allowed, same with the line below it. I am trying to go from button1 to button2 etc for each line that is read.
The next item that I have a problem with is passing a variable to another sub routine. For example having the button_xPath created within the formload routine and then not passed down to the button1 code. I would have code for each button on the form but want to use the variable to store the path to the file that should be run.
Any help or suggestions would be great.
Cheers
Baz.
The xml file just lists a program name (which would become the button text) and the path to the file (which should be stored as a variable that is used in the button code (handle?)
The idea is that I have an app that once created, I just update the xml file with new drivers or programs that I want to install or run without having to rebuild the application.
VB.NET:
Imports System.IO
Imports System.Xml
Imports System
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim idx = 1
Dim settings As New XmlReaderSettings()
settings.IgnoreComments = True
Dim XMLfile As String = Application.StartupPath & "_AutoStart\config.xml"
Using reader As XmlReader = XmlReader.Create(XMLfile, settings)
While (reader.Read())
If (reader.NodeType = XmlNodeType.Element And "name" = reader.LocalName) Then
Dim NameValue = reader.ReadElementString("name")
Dim PathValue = reader.ReadElementString("path")
Dim button_x = "Button" & idx
button_x.Text = NameValue
button_x.Visible = True
Dim button_xPath
button_xPath = PathValue
idx = idx + 1
'MsgBox(NameValue & " " & PathValue)
End If
End While
End Using
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
System.Diagnostics.Process.Start(button_xPath)
End Sub
End Class
As you would see the line "button_x.Text = NameValue" is not allowed, same with the line below it. I am trying to go from button1 to button2 etc for each line that is read.
The next item that I have a problem with is passing a variable to another sub routine. For example having the button_xPath created within the formload routine and then not passed down to the button1 code. I would have code for each button on the form but want to use the variable to store the path to the file that should be run.
Any help or suggestions would be great.
Cheers
Baz.