How do you load a form that reads a file and fills in defaults

wrxdriven

Member
Joined
Sep 23, 2003
Messages
16
I ahve a windows for that i want to start up and fill in text boxs with a default .

Here is my file it is a .cfg file.

[Schedule]
loan=250000
interest=4.25
years=30
payment=1229.85
HTML=c:\syst2010\schedule.html
I want it to read line by line into my text boxes

such as loan=250000 goes into the Loan txt box.

Please help me...
thanks
 
something like this maybe ...
Code:
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim sReader As IO.StreamReader ///use the System.IO.StreamReader / System.IO.StreamWriter rather than the FreeFile method.
        Dim path As String = "C:\myFile.txt"
        Dim sLine As String
        Try
            sReader = New IO.StreamReader(New IO.FileStream(path, IO.FileMode.Open))
            While Not sReader.Peek
                sLine = sReader.ReadLine
                Select Case sLine.Split("=")(0) /// the text to the left of the = symbol.
                    Case "loan"
                        MessageBox.Show(sLine.Split("=")(1)) /// the value at the right of the = symbol.
                        /// do what you want to the value ( eg: add to textbox called Loan )
                    Case "interest"
                        MessageBox.Show(sLine.Split("=")(1))
                        /// and so on...
                End Select
            End While
            sReader.Close()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub
 
Back
Top