property Command.Caption as String

Retrieves or sets a value that indicates the caption of the item menu.

TypeDescription
String A string expression that indicates the caption of the item menu.

Use Caption property to get the command's caption that user has selected. Use the Command property of the control to get a Command object based on the item's identifier. You can use Caption property of Item object to retrieves the items' caption. The Caption property may include built-in HTML tags like follows:

The following sample shows how to get the caption of the menu item that has been selected on the popup menu:

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If (Button = 2) Then
        Dim nID As Long
        nID = PopupMenu1.ShowAtCursor
        If (nID > 0) Then
            MsgBox "You have selected the '" & PopupMenu1.Command(nID).Caption & "'"
        End If
    End If
End Sub