Click here to Skip to main content
15,892,480 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
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
Comments
Logi Guna 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

C#
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);

}
 
Share this answer
 
Comments
San Dra 18-Jan-13 12:31pm    
Thank You !! I fixed it :)
i think your combo box name is wrong..
i think it is : "cmdShow" not ComboBox1
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900