先在菜单设计器中设置菜单(如:mununame1)
然后
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
if button =2 then '2是鼠标右键
popupMenu mununame1
end if
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 165
ClientTop = 735
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.Menu mnu_file
Caption = "File"
Begin VB.Menu mnu_open
Caption = "Open"
End
Begin VB.Menu mnu_bar
Caption = "-"
End
Begin VB.Menu mnu_exit
Caption = "E&xit"
End
End
Begin VB.Menu mnu_edit
Caption = "Edit"
Begin VB.Menu mnu_Copy
Caption = "Copy"
End
Begin VB.Menu mnu_cut
Caption = "Cut"
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Select Case Button
Case 2
PopupMenu mnu_edit
End Select
End Sub