user5857081
user5857081

Reputation:

Display the result of an optionButton in a messageBox

I have a problem in displaying the selected option in the user form. I have 2 option buttons named opt750 and the value is 750 and the other one is opt1000 and the value is 1000.After selecting from the options, it should be displayed in the msg box. The code I've tried is as follows, this is the whole message to be displayed when the user click the ok button:

MsgBox "Date Received : " & vbTab + vbTab + date.Value + vbNewLine & _
"Amount Received : " & vbTab + amount.Value + vbNewLine & _
"Received Type: " & vbTab + vbTab + acnType.Value + vbNewLine & _
vbNewLine & _
"Received the amount of : " 'this is where I should 
'call the result of the selected option button

I like the result to be displayed in the msgbox as:

Date Received : 01/01/2011
Amount Received: 10000
Received Type: ATM
Received the total amount of : 750 'if the button selected is 750 otherwise, 1000

Thanks a lot!

Upvotes: 0

Views: 991

Answers (1)

Siva
Siva

Reputation: 1149

Assuming you have a user form with some option like below...

enter image description here

On Click of OK button message box will be displayed for my below code based on the user selection option.

 Private Sub CommandButton1_Click()
        Dim amt As Integer
        If (opt750) Then
          amt = 750
        ElseIf (opt1000) Then
          amt = 1000
          Else
          amt = 0
        End If
        MsgBox "Received the amount of :" & amt

 End Sub

Upvotes: 1

Related Questions