loyal Posted August 16, 2003 Posted August 16, 2003 Hi all I stuck with syntax error that when I want to reset all controls In my form controls by using this code but the Combo Box give the below Tip How can I solve this Quote Gary Says: To be a good programmer, you must be good at debugging
*Experts* mutant Posted August 16, 2003 *Experts* Posted August 16, 2003 Thats a weird error, never had it before. Does ComboBox show when IntelliSense pops up after "Is"? Did you try using Windows.Forms.ComboBox, as this is the full path to it. Quote
loyal Posted August 16, 2003 Author Posted August 16, 2003 yes it does but now solved by your solution ElseIf TypeOf ctrl Is Windows.Forms.ComboBox Then Thanks a lot Quote Gary Says: To be a good programmer, you must be good at debugging
*Experts* mutant Posted August 16, 2003 *Experts* Posted August 16, 2003 :) But still, what you did should work because I see that you use TextBox without the full namespace name so it must be imported and TextBox is in the same namespace as ComboBox so if it works, ComboBox should work too. Quote
*Experts* Volte Posted August 16, 2003 *Experts* Posted August 16, 2003 Is there a variable in your code called "ComboBox"? That will throw it off, most likely. Quote
*Experts* mutant Posted August 16, 2003 *Experts* Posted August 16, 2003 I think you are right VolteFace, if the full namespace path works, that must be the cause. Quote
loyal Posted August 16, 2003 Author Posted August 16, 2003 (edited) no I am sure that there's no variable hold this name I have only 2 vars one is array that hold the ComboBox display Memebers and strMessage as string that's all I'll upload the project to validate :cool: here's the code Dim strArray() As String = {"a", "b", "c", "d"} Dim strMessage As String Private Sub Form1_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load cb.Items.AddRange(strArray) End Sub Private Sub cb_SelectedIndexChanged( _ ByVal sender As System.Object, ByVal e _ As System.EventArgs) Handles cb.SelectedIndexChanged strMessage = "The value is " & CStr(cb.SelectedIndex) MessageBox.Show(strMessage) End Sub Private Sub btnReset_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnReset.Click Dim ctrl As Control For Each ctrl In Me.Controls Try If TypeOf ctrl Is TextBox Then ctrl.Text = "" 'TODO:HOW TO RESET THE COMBOBOX CONTROL ElseIf TypeOf ctrl Is Windows.Forms.ComboBox Then ctrl.ResetText() End If Catch ex As Exception MessageBox.Show(ex.Message) End Try Next End Sub combobox.zip Edited March 15, 2007 by PlausiblyDamp Quote Gary Says: To be a good programmer, you must be good at debugging
*Experts* mutant Posted August 16, 2003 *Experts* Posted August 16, 2003 That explains it :). Your project and solution are called ComboBox, which makes the rootspace of your project to be "ComboBox". It was interpreted as a namespace, thats why it wanted a type, because it was getting a namespace name. Quote
loyal Posted August 16, 2003 Author Posted August 16, 2003 Ohhhhhh yeah that's realy deep mistake Thanks a million (***&***) well it solved by just chanaged the Root namespace from ComboBox To AppComboBox Quote Gary Says: To be a good programmer, you must be good at debugging
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.