IF Statements

paulthepaddy

Well-known member
Joined
Apr 9, 2011
Messages
222
Location
UK
Programming Experience
Beginner
hi guys, i cant figure out wh this code doesn't work the selected index changed calls the sub pass_maker

but pass_maker is only working the 1st tme round

VB.NET:
Private Sub ComboBox_Car_Maker_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox_Car_Maker.SelectedIndexChanged
        Me.ComboBox_Car_Colour.Items.Clear()
        Me.ComboBox_Car_Colour.Text = ""
        Me.ComboBox_Car_Colour.Enabled = True
        Me.ComboBox_Car_Model.Items.Clear()
        Me.ComboBox_Car_Model.Text = ""
        Me.ComboBox_Car_Model.Enabled = True
        Me.CheckBox_Full_Colours.Enabled = True
        Using r As StreamReader = New StreamReader(Application.StartupPath & "\Resourses\" & Me.ComboBox_Car_Maker.Text & "\Car_Model.txt")
            Dim line As String
            line = r.ReadLine
            Do While (Not line Is Nothing)
                Me.ComboBox_Car_Model.Items.Add(line)
                line = r.ReadLine
            Loop
        End Using
        Using r As StreamReader = New StreamReader(Application.StartupPath & "\Resourses\Colours.txt")
            Dim line As String
            line = r.ReadLine
            Do While (Not line Is Nothing)
                Me.ComboBox_Car_Colour.Items.Add(line)
                line = r.ReadLine
            Loop
        End Using
        Call pass_maker()
    End Sub
when car1.finished = true it doesn't move onto 'ElseIf car2.finished = False then' and car1.finished is definatly true and car2.finished is defeinatly false
im confused lol
EDIT: Just to clarify i am changing the index twich so it cals the sub a second time after it has finished car1.finished = false
VB.NET:
 Public Sub pass_maker()
        If car1.finished = False Then
            car1.Make = ComboBox_Car_Maker.Text
            lbl_Car1_Make.Text = ComboBox_Car_Maker.Text
        ElseIf car2.finished = False Then
            car2.Make = ComboBox_Car_Maker.Text
            lbl_Car2_Make.Text = ComboBox_Car_Maker.Text
        ElseIf car3.finished = False Then
            car3.Make = ComboBox_Car_Maker.Text
            lbl_Car3_make.Text = ComboBox_Car_Maker.Text
        ElseIf car4.finished = False Then
            car4.Make = ComboBox_Car_Maker.Text
            lbl_Car4_Make.Text = ComboBox_Car_Maker.Text
        ElseIf car5.finished = False Then
            car5.Make = ComboBox_Car_Maker.Text
            lbl_Car5_Make.Text = ComboBox_Car_Maker.Text
        ElseIf car6.finished = False Then
            car6.Make = ComboBox_Car_Maker.Text
            lbl_Car6_Make.Text = ComboBox_Car_Maker.Text
       ElseIf car7.finished = False Then
            car7.Make = ComboBox_Car_Maker.Text
            lbl_Car7_Make.Text = ComboBox_Car_Maker.Text
        ElseIf car8.finished = False Then
            car8.Make = ComboBox_Car_Maker.Text
            lbl_Car8_Make.Text = ComboBox_Car_Maker.Text
        ElseIf car9.finished = False Then
            car9.Make = ComboBox_Car_Maker.Text
            lbl_Car9_Make.Text = ComboBox_Car_Maker.Text
        ElseIf car10.finished = False Then
            car10.Make = ComboBox_Car_Maker.Text
            lbl_Car10_Make.Text = ComboBox_Car_Maker.Text
        End If
    End Sub
 
sorry my mistake, the code that finished the car was only done for the 1st car so it finished them all at once no problem here, thread can be deleted
 
Back
Top