Using INI files in VB.NET

johnadonaldson

Well-known member
Joined
Nov 9, 2005
Messages
48
Programming Experience
10+
I have a project which needs to read/write existing INI files. I have the code to Read/Write INI files, except it’s not clear how to extract elements. Below is the code to read in text values and int values, but it is not clear How to access each element call by the variable “s”.


Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
Dim sb As StringBuilder = New StringBuilder(5000)
Dim sc As StringCollection = New StringCollection()
Dim fi As FileInfo = New FileInfo(Me.txtFilename.Text)
Dim filename As String = txtFilename.Text
Dim s As String
If fi.Exists Then

sc = INIWrapper.GetINISection(filename, "textvalues")

For Each s In sc
sb.Append(" " & s & "" & NewLine)
Next
sb.Append("" & NewLine)


TextBox1.Text = s
TextBox2.Text = s
TextBox3.Text = s

sc = INIWrapper.GetINISection(filename, "intvalues")

For Each s In sc
sb.Append(" " & s & "" & NewLine)
Next
sb.Append("" & NewLine)


TextBox4.Text = s
TextBox5.Text = s
TextBox6.Text = s
 
Back
Top