Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am trying to read the activation of toolbar button using a case

statement. I can read them fine using if statements, but tht seems unefficient.

 

The problem is, i keep getting a blue line under the is.

 

   Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick

       select e.Button is
           Case tbrOptions

           Case tbrConnect

           Case tbrPause

           Case tbrExit
       End Select

   End Sub

 

Thanks.

  • *Experts*
Posted

You would have to do this:

Select Case ToolBar1.Buttons.IndexOf(e.Button)

This will return to you the index of the button, and you then choose what to do based on the index.

  • *Experts*
Posted
You can use an If..EndIf block in this way.
If e.Button Is tbrOptions Then
 'Blah
ElseIf e.Button is tbrConnect Them
 'Blah
 'etc
End If

Not much different than a Select Case statement. This way you can reorder them without messing up the indexes.

Posted

Yeah i used the elseif statements when i couldnt figure out the case statements. I made the post, so i could see where i was going wrong.

 

Thanks again

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...