Question String from text file for combobox default?

Graham Dyer

New member
Joined
May 8, 2009
Messages
2
Programming Experience
Beginner
I have the following lines in a text file:

#define roll_P 0.8 // Roll Proportional
#define roll_I 1.5 // Roll Intergrator

I want to read the '0.8' from the text file and load it into ComboBox1 as the default value, then I want to read the '1.5' and load it into ComboBox2 as the default value.

But I can't get the value to show in the ComboBox on runtime, it only shows when I select any value in the ComboBox? Is my ComboBox event wrong?

VB.NET:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Using SR As New System.IO.StreamReader("C:/test.txt")
            While Not SR.EndOfStream
                Dim Theline As String = SR.ReadLine
                    If Theline.Contains("#define roll_P ") Then
                    ComboBox1.Text = Mid(Theline, 16, 3)
                    MsgBox(ComboBox1.Text) 'to show what's been read
                    Exit While
                Else
                    MsgBox("Error")
                End If
            End While
            SR.Close()
        End Using
    End Sub

My idea is to find the line with specific text, read the digits after that text and use those as default start values for the comboboxes. Perhaps I'm going about it the wrong way?
 
Back
Top