hey guys!

how can I read strings from a file? Like... They will compose part of the interface... something like, read a string from a file, then this string points to a image that will be used in a picture box, as same as a label that will be shown with the read value.

I first thought on a xml file... or a ini too, to separate entries.

Something like this:

!-- Entry one
[Entry One]
Name=Some name
Icon=C:\path\to\icon
Command= !-- do something here

[Entry Two]
Name=Some name 2
Icon=C:\path\to\icon\2
Command = !-- do something here

and so on...

There is someway to do it? Thanks!

If your INI File content is exactly as you have posted, see if this helps.

Public Class Form1
    Private myFile As String = "C:\test.txt" '// your File.
    Private arlFileInfo As New ArrayList '// ArrayList to store Information for each Entry.
    Dim arTemp() As String = Nothing '// String Array to use as needed.

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If IO.File.Exists(myFile) Then '// check if File Exists.
            arTemp = IO.File.ReadAllLines(myFile) '// Read each Line into a String Array.
            For i As Integer = 0 To arTemp.Length - 1 '// Loop thru all Lines.
                If arTemp(i).StartsWith("[Entry") Then '// If Line .StartsWith("[Entry").
                    '// Add 1st, 2nd, and 3rd Lines following the Line that .StartsWith("[Entry") as New Item to your Array List.
                    arlFileInfo.Add(arTemp(i + 1) & "~" & arTemp(i + 2) & "~" & arTemp(i + 3)) '// "~" used to .Split Item when extracting data from Item.
                End If
            Next
        End If
        '//======== DISPLAY RESULT FOR SECOND ENTRY =======
        arTemp = arlFileInfo(1).ToString.Split("~") '// split Item 2 by the "~" char.
        '// Display result.
        MsgBox(arTemp(0) & vbNewLine & arTemp(1) & vbNewLine & arTemp(2), MsgBoxStyle.Information) '======\\
        '//======== DISPLAY RESULT FOR FIRST ENTRY =======
        arTemp = arlFileInfo(0).ToString.Split("~") '// split Item 1 by the "~" char.
        '// Display result.
        MsgBox(arTemp(0) & vbNewLine & arTemp(1) & vbNewLine & arTemp(2), MsgBoxStyle.Information) '======\\
    End Sub
End Class

woah, thanks!

I'll try it out. Since I posted, I've been looking for another ways, now I'll decide if its better use this or a SQLite database (:

Thanks again!

Well, appears that using SQLite will be better. It can store everything inside a one file, which sounds better to me. I've also found a nice tutorial written in portuguese (my main language), that helped me a lot.

So, I'll use SQLite. But this piece of code its nice too. I might use it too (: Thanks!

This question has already been answered. Start a new discussion instead.