Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
Code help for Menu, pop up menu

If Button = vbRightButton Then PopupMenu Me.mnuPopup




Private txtName_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As
Single)

If Button=vbRightButton Then

PopupMenu mnuEdit

End If

End Sub



How do I find out what menu item was clicked

str = popMenu.Name
Select Case str
Case "mCut"
MsgBox "cut"
Case "mPaste"
MsgBox "paste"
Case "mProperties"
MsgBox "pro"

End Select



Popup menu coding

         Private Sub lblTestText_MouseDown(Button As Integer, _
                                           Shift As Integer, _
                                           X As Single, _
                                           Y As Single)

             If Button = vbRightButton Then
                 PopupMenu mnuPopUpFormat, vbPopupMenuRightButton
             End If

         End Sub
Code for bold
      Private Sub mnuBold_Click()

           If mnuBold.Checked Then
                lblTestText.FontBold = False
                mnuBold.Checked = False
           Else
                lblTestText.FontBold = True
                mnuBold.Checked = True
           End If

      End Sub

Code the mnuItalic_Click and mnuUnderline_Click events in a similar fashion as shown
      below.
      Private Sub mnuItalic_Click()

           If mnuItalic.Checked Then
                lblTestText.FontItalic = False
                mnuItalic.Checked = False
           Else
                lblTestText.FontItalic = True
                mnuItalic.Checked = True
           End If

      End Sub

      Private Sub mnuUnderline_Click()

           If mnuUnderline.Checked Then
                lblTestText.FontUnderline = False
                mnuUnderline.Checked = False
           Else
                lblTestText.FontUnderline = True
                mnuUnderline.Checked = True
           End If

      End Sub




MsgBox "Code for 'Print' goes here.", vbInformation, "Menu Demo"



      Private Sub mnuBold_Click()
      If mnuBold.Checked Then
      lblTestText.FontBold = False
      mnuBold.Checked = False
Else
lblTestText.FontBold = True
mnuBold.Checked = True
End If
End Sub

More Related Content

Menu vb

  • 1. Code help for Menu, pop up menu If Button = vbRightButton Then PopupMenu Me.mnuPopup Private txtName_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button=vbRightButton Then PopupMenu mnuEdit End If End Sub How do I find out what menu item was clicked str = popMenu.Name Select Case str Case "mCut" MsgBox "cut" Case "mPaste" MsgBox "paste" Case "mProperties" MsgBox "pro" End Select Popup menu coding Private Sub lblTestText_MouseDown(Button As Integer, _ Shift As Integer, _ X As Single, _ Y As Single) If Button = vbRightButton Then PopupMenu mnuPopUpFormat, vbPopupMenuRightButton End If End Sub
  • 2. Code for bold Private Sub mnuBold_Click() If mnuBold.Checked Then lblTestText.FontBold = False mnuBold.Checked = False Else lblTestText.FontBold = True mnuBold.Checked = True End If End Sub Code the mnuItalic_Click and mnuUnderline_Click events in a similar fashion as shown below. Private Sub mnuItalic_Click() If mnuItalic.Checked Then lblTestText.FontItalic = False mnuItalic.Checked = False Else lblTestText.FontItalic = True mnuItalic.Checked = True End If End Sub Private Sub mnuUnderline_Click() If mnuUnderline.Checked Then lblTestText.FontUnderline = False mnuUnderline.Checked = False Else lblTestText.FontUnderline = True mnuUnderline.Checked = True End If End Sub MsgBox "Code for 'Print' goes here.", vbInformation, "Menu Demo" Private Sub mnuBold_Click() If mnuBold.Checked Then lblTestText.FontBold = False mnuBold.Checked = False