You could do it this way also:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Select Case ComboBox1.SelectedIndex
Case 1
frmWeek1.Show()
ComboBox1.SelectedIndex = -1 ' Clears the Selected Index
Case 2
frmWeek2.Show()
ComboBox1.SelectedIndex = -1 ' Clears the Selected Index
Case 3
frmWeek3.Show()
ComboBox1.SelectedIndex = -1 ' Clears the Selected Index
Case 4
frmWeek4.Show()
ComboBox1.SelectedIndex = -1 ' Clears the Selected Index
End Select
End Sub
assuming you added items the following way:
ComboBox1.Items.Add("") 'Index 0
ComboBox1.Items.Add("Week1") 'Index 1
ComboBox1.Items.Add("Week2") 'Index 2
ComboBox1.Items.Add("Week3") 'Index 3
ComboBox1.Items.Add("Week4") 'Index 4
This way you do not have to worry about casing.
Or you could use LCASE (makes text all lower case) and UCASE (makes all upper case) then you wont get caught out.
LOWER CASING
If lcase(ComboBox1.Text) = "week1" Then
frmWeek1.show
Else if lcase(ComboBox1.text) = "week2" Then
frmWeek2.show
'etc
End if
UPPER CASING:
If ucase(ComboBox1.Text) = "WEEK1" Then
frmWeek1.show
Else if ucase(ComboBox1.text) = "WEEK2" Then
frmWeek2.show
'etc
End if
Cheers
Darren
DGULLIVER
Junior Poster in Training
74 posts since Mar 2004
Reputation Points: 20
Solved Threads: 4