' Uses config files with a "variable=value" structure
    ' Function to read config file and parse out values
    Public Sub ReadConfig()
        Dim objStreamReader As System.IO.StreamReader
            ' Open config file
            objStreamReader = System.IO.File.OpenText(FILENAME)
            'Now, read the entire file into a string
            Dim contents As String = objStreamReader.ReadToEnd()
            'Close file
            ' Split lines
            contents = Replace(contents, vbNewLine, ":", , , vbTextCompare)
            Dim lines As String() = contents.Split(New Char() {":"c})
            ' Parse config file
            Dim line As String
            For Each line In lines
                Dim values As String() = line.Split(New Char() {"="c})
                Select Case values(0)
                    Case "host" : host = values(1)
                    Case "dbname" : db = values(1)
                    Case "user" : user = values(1)
                    Case "pass" : pass = values(1)
                End Select
        Catch ex As Exception
            MsgBox("Can not read config!")
        End Try
    End Sub
    ' Function to write new config file
    Public Sub WriteConfig()
        ' open config file
        Dim objStreamWriter As System.IO.StreamWriter
        objStreamWriter = System.IO.File.CreateText(FILENAME)
        Dim fileString As String
        fileString = "host=" + host + vbNewLine + "dbname=" + db + vbNewLine + "user=" + user + vbNewLine + "pass=" + pass
        'message(fileString) ' Debug line
        'Re-write file
        'Close the stream
    End Sub