Hi, beginner VB user here.
There's an INI file that I want to access and read information from. This is the complete content of the file in question:
http://www.heypasteit.com/clip/0C3Q[
^]
My form has a bunch of comboboxes, trackbars and checkboxes. These items needs to be filled by the information taken from the INI file.
Here's how the INI file is formatted;
...
[Display]
bCrosshairEnabled=1
bDoDepthOfField=0
bFXAAEnabled=1
uiMaxSkinnedTreesToRender=10
iSize H=720
iSize W=1280
[Controls]
bGamepadEnable=1
...
What I want is make my form items reflect the values in the INI file. For instance,I want CheckBox8 in my form to get checked if
bFXAAEnabled
has a value of "1" and unchecked if it is "0" vice versa...
So far I couldn't find a way to do it can you please provide me a solution?.
I'm using Visual Basic 2010 and I'm such a noob at VB programming so please explain your code if possible.
Thanks in advance.
UPDATE 1
OK I found this solution
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Text.RegularExpressions
Imports System.IO
Dim fName As String = (dir + "\My Games\Skyrim\SkyrimPrefs.ini")
Dim testTxt As New StreamReader(fName)
Dim allRead As String = testTxt.ReadToEnd()
testTxt.Close()
Dim regMatch As String = "bCrosshairEnabled"
If Regex.IsMatch(allRead, regMatch) Then
Else
End If
Now if only i could find a code that does something according to value comes after "=".
Such as:
If bCrosshairEnabled="1" then
ELSE
End if
UPDATE 2
Can anybody tell me how to combine this code with the one above to create a solution to my problem?
For Each line As String In IO.File.ReadLines("text file path")
Dim ary As String() = line.Split("="c)
If IsNumeric(ary(1)) Then
Dim valuePair As New KeyValuePair(Of String, Integer)(ary(0), CInt(ary(1)))
Dim value As Integer = CInt(ary(1))
Select Case value
Case 1
Case 2
Case Else
End Select
End If
Next