468,253 Members | 1,241 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,253 developers. It's quick & easy.

ComboBox And Panel

Hello, I am making an application where You will select a color from a combo box and after pressing select button it would show what "Inside Out" Movie character you are. The Characters are in 5 Different hidden panels.

My problem is that it's showing this error:
Error 2 Operator '=' is not defined for types 'System.Windows.Forms.ComboBox' and 'Integer'

How should I make this?
Here's my Code
Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.     Private Sub ColorListComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ColorListComboBox.SelectedIndexChanged
  3.  
  4.     End Sub
  5.  
  6.     Private Sub Selectbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Selectbtn.Click
  7.         Select Case ColorListComboBox
  8.             Case 0
  9.                 Angerpnl.Visible = True
  10.             Case 1
  11.                 Joypnl.Visible = True
  12.             Case 2
  13.                 Joypnl.Visible = True
  14.             Case 3
  15.                 Sadnesspnl.Visible = True
  16.             Case 4
  17.                 Disgustpnl.Visible = True
  18.             Case 5
  19.                 Disgustpnl.Visible = True
  20.             Case 6
  21.                 Fearpnl.Visible = True
  22.             Case 7
  23.                 Fearpnl.Visible = True
  24.             Case 8
  25.                 Joypnl.Visible = True
  26.             Case 9
  27.                 Angerpnl.Visible = True
  28.             Case 10
  29.                 Angerpnl.Visible = True
  30.             Case 11
  31.                 Sadnesspnl.Visible = True
  32.             Case 12
  33.                 Disgustpnl.Visible = True
  34.             Case 13
  35.                 Fearpnl.Visible = True
  36.             Case 14
  37.                 Sadnesspnl.Visible = True
  38.             Case Else
  39.                 Errorlbl.Visible = True
  40.         End Select
  41.     End Sub
  42.  
  43.     Private Sub Exitbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Exitbtn.Click
  44.         End
  45.     End Sub
  46.  
  47. End Class
  48.  
  49.  
  50.  
Attach is a Scrrencap of my Design
Attached Images
File Type: jpg Untitled.jpg (212.8 KB, 8 views)
Dec 4 '20 #1

✓ answered by CollegeStud

Answer:
Public Class Form1
Private Sub ColorListComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ColorListComboBox.SelectedIndexChanged

End Sub

Private Sub Selectbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Selectbtn.Click
Select Case ColorListComboBox.SelectedIndex
Case 0
Angerpnl.Visible = True
Case 1
Joypnl.Visible = True
Case 2
Joypnl.Visible = True
Case 3
Sadnesspnl.Visible = True
Case 4
Disgustpnl.Visible = True
Case 5
Disgustpnl.Visible = True
Case 6
Fearpnl.Visible = True
Case 7
Fearpnl.Visible = True
Case 8
Joypnl.Visible = True
Case 9
Angerpnl.Visible = True
Case 10
Angerpnl.Visible = True
Case 11
Sadnesspnl.Visible = True
Case 12
Disgustpnl.Visible = True
Case 13
Fearpnl.Visible = True
Case 14
Sadnesspnl.Visible = True
Case Else
Errorlbl.Visible = True
End Select
End Sub

Private Sub Exitbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Exitbtn.Click
End
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ColorListComboBox.Items.Add(" Red ")
ColorListComboBox.Items.Add(" Orange ")
ColorListComboBox.Items.Add(" Yellow ")
ColorListComboBox.Items.Add(" Blue ")
ColorListComboBox.Items.Add(" Green ")
ColorListComboBox.Items.Add(" Indigo ")
ColorListComboBox.Items.Add(" Purple ")
ColorListComboBox.Items.Add(" Turquoise ")
ColorListComboBox.Items.Add(" Pink ")
ColorListComboBox.Items.Add(" Brown ")
ColorListComboBox.Items.Add(" Gray ")
ColorListComboBox.Items.Add(" Silver ")
ColorListComboBox.Items.Add(" Gold ")
ColorListComboBox.Items.Add(" White ")
ColorListComboBox.Items.Add(" Black ")
End Sub
End Class

1 2285
Answer:
Public Class Form1
Private Sub ColorListComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ColorListComboBox.SelectedIndexChanged

End Sub

Private Sub Selectbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Selectbtn.Click
Select Case ColorListComboBox.SelectedIndex
Case 0
Angerpnl.Visible = True
Case 1
Joypnl.Visible = True
Case 2
Joypnl.Visible = True
Case 3
Sadnesspnl.Visible = True
Case 4
Disgustpnl.Visible = True
Case 5
Disgustpnl.Visible = True
Case 6
Fearpnl.Visible = True
Case 7
Fearpnl.Visible = True
Case 8
Joypnl.Visible = True
Case 9
Angerpnl.Visible = True
Case 10
Angerpnl.Visible = True
Case 11
Sadnesspnl.Visible = True
Case 12
Disgustpnl.Visible = True
Case 13
Fearpnl.Visible = True
Case 14
Sadnesspnl.Visible = True
Case Else
Errorlbl.Visible = True
End Select
End Sub

Private Sub Exitbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Exitbtn.Click
End
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ColorListComboBox.Items.Add(" Red ")
ColorListComboBox.Items.Add(" Orange ")
ColorListComboBox.Items.Add(" Yellow ")
ColorListComboBox.Items.Add(" Blue ")
ColorListComboBox.Items.Add(" Green ")
ColorListComboBox.Items.Add(" Indigo ")
ColorListComboBox.Items.Add(" Purple ")
ColorListComboBox.Items.Add(" Turquoise ")
ColorListComboBox.Items.Add(" Pink ")
ColorListComboBox.Items.Add(" Brown ")
ColorListComboBox.Items.Add(" Gray ")
ColorListComboBox.Items.Add(" Silver ")
ColorListComboBox.Items.Add(" Gold ")
ColorListComboBox.Items.Add(" White ")
ColorListComboBox.Items.Add(" Black ")
End Sub
End Class
Dec 4 '20 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

17 posts views Thread by Newbie | last post: by
7 posts views Thread by Lauren Quantrell | last post: by
reply views Thread by kermitthefrogpy | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.