hi everyone :)

I hate to do this but I gotta..

This is what I want to do but dont have the foggiest about how to accomplish it!

I have 4 forms..frmWeekOne, frmWeekTwo, frmWeekThree, frmWeekFour.

These 4 forms are all added forms to my original project.

what I need to happen here..is when the user clicks on Week 1..I need it to open frmWeekOne..and so on.

Originally I had buttons to do this but it made my windows app project look waaaaaay too gaudy..so I decided to try one of these contoller things..ComboBox. I put the combobox on my form and added Week 1..Week 2...Week 3...week 4...

The problem is is how the heck do I get it to where the user clicks on week 1..and frmWeekOne opens? or if they click on Week 2...frmWeekTwo opens??

I have only been using visual studio 2008 for about 2 weeks...LOL..and thats about all the coding experience I have as well.

any help will be greatly appreciated, and the faster the better..as I only have a short time to get this all together :(

ThanxxXXXXXXXXXXX :)

Recommended Answers

All 7 Replies

Go to the coding of the button, and if put in what your form is called .show
So if your weel one form is called "FrmWeekone", then you would type in "FrmWekkone.show"

Get it?

I think you double-click on the control (should be combobox1.valuechanged) and use something like

If ComboBox1.Text = "replace with your option 1 week here" Then
Forma.show
Else if ComboBox1.text = "week2" Then
Formb.show
'You get the idea..
End if

I think you double-click on the control (should be combobox1.valuechanged) and use something like

If ComboBox1.Text = "replace with your option 1 week here" Then
Forma.show
Else if ComboBox1.text = "week2" Then
Formb.show
'You get the idea..
End if

Thank you for helping :)

but for some reason, It will not open the form :(
I dont have any errors showing, but for some reason it will not open for me.

Hey, the code is case sensitive, make sure if the text is "XXxxXX" you have it exactly like thatl.

Hey, the code is case sensitive, make sure if the text is "XXxxXX" you have it exactly like thatl.

ahhhhhhhhhhhh There it is :)
Thank ya thank ya an Thank YA!

the capitals did it..LOL..week..Week..sheesh!

Thanks Again!

Hey, no problem, glad to of helped!

commented: Again Thank YA :) +1

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

commented: very detailed, Thanks :) +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.