Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Gary Says: To be a good programmer, you must be good at debugging
  • *Experts*
Posted
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.
Posted

yes it does

 

but now solved by your solution

 

ElseIf TypeOf ctrl Is Windows.Forms.ComboBox Then

 

Thanks a lot

Gary Says: To be a good programmer, you must be good at debugging
  • *Experts*
Posted

:)

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.

Posted (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 by PlausiblyDamp
Gary Says: To be a good programmer, you must be good at debugging
  • *Experts*
Posted

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.

Posted

Ohhhhhh yeah that's realy deep mistake

 

Thanks a million (***&***)

 

well it solved by just chanaged the

 

Root namespace from ComboBox To AppComboBox

Gary Says: To be a good programmer, you must be good at debugging

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...