Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB VisualStudio2012
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
 
        ComboBox1.Items.Add("4")
        ComboBox1.Items.Add("5")
        ComboBox1.Items.Add("6")
        ComboBox1.Items.Add("7")
        ComboBox1.Items.Add("8")
        ComboBox1.Items.Add("9")
        ComboBox1.Items.Add("10")
        ComoBox1.SelectedItem = 0
 
End Sub
 

Private Sub cmdShow_Click(sender As Object, e As EventArgs) Handles cmdShow.Click
 
Dim Message As string
Message = "Your items are " + ComboBox1.Text ... + vbCr
MsgBox(Message, vbOKOnly + vbInformation, "Your Items")
 
End sub
 

 

 

It shows an error in Message that "ComboBox1 is not declared. It may be inaccessible due to its protection level"
 
How can I display ComboBox1.Text..
I have many cboName.Text, but i put one for example.
Thank you!
Posted 18-Jan-13 1:25am
San Dra391
Comments
Logi Guna at 18-Jan-13 10:27am
   
search "Private WithEvents ComboBox1" in entire solution
replace with "Public WithEvents ComboBox1"
also search "Friend WithEvents ComboBox1"
replace with "Public WithEvents ComboBox1"
don't replace all, just ComboBox do you want to display
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

i think your combo box name is wrong..
i think it is : "cmdShow" not ComboBox1
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

private void Form1_Load(object sender, EventArgs e)
{
 
    comboBox1.Items.Add("4");
    comboBox1.Items.Add("5");
    comboBox1.Items.Add("6");
    comboBox1.Items.Add("7");
    comboBox1.Items.Add("8");
    comboBox1.Items.Add("9");
    comboBox1.Items.Add("10");
 
    // Please check your code their is spelling mistake Comobox1 and change to SelectedIndex to show 1st item in list
    comboBox1.SelectedIndex = 0;
 
}
 
private void button1_Click(object sender, EventArgs e)
{
 
    string Message = String.Format("Your Items are {0}\r\n", comboBox1.Text);
 
    MessageBox.Show(Message, "Your Item", MessageBoxButtons.OK);
 
}
  Permalink  
Comments
San Dra at 18-Jan-13 12:31pm
   
Thank You !! I fixed it :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 386
1 Marcin Kozub 225
2 Sergey Alexandrovich Kryukov 215
3 /\jmot 189
4 Praneet Nadkar 173
0 OriginalGriff 8,289
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,624
3 Maciej Los 4,989
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 18 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100