Josh F
Josh F

Reputation: 37

Add Title to message box with several lines

I've got an about message box which when the user presses a button, a message box opens and prints information about the software, on several lines. In an attempt to make it look neater, I wish to remove the 'Microsoft Excel' title for the message box. What I did was I put two commas after the message, which I normally do, but with one line of text but I keep getting expression errors with an equals sign or an invalid syntax error. Could someone help?

Here's my current code :)

    Private Sub about_button_Click()
    MsgBox ("Name: gemUI" & vbCrLf & "Version: 1.0" & vbCrLf & "Build: 0001" & _
    vbCrLf & "(C) 2018 Josh Face", , "About gemUI")
    End Sub

If anyone could help, it would be greatly appreciated :) Have a good evening :)

Josh

Upvotes: 0

Views: 2684

Answers (2)

DisplayName
DisplayName

Reputation: 13386

just to add a (maybe) less clumsy way:

MsgBox Join(Array("Name: gemUI", "Version: 1.0", "Build: 0001", "(C) 2018 Josh Face"), vbCrLf), , "About gemUI"

Upvotes: 0

John Alexiou
John Alexiou

Reputation: 29244

You have one too many parentheses. Ether take out the outside parenthesis surrounding the arguments or use the Call keyword.

Private Sub about_button_Click()
    MsgBox "Name: gemUI" & vbCrLf & "Version: 1.0" & vbCrLf & "Build: 0001" & _
        vbCrLf & "(C) 2018 Josh Face", , "About gemUI"
End Sub

or

Private Sub about_button_Click()
    Call MsgBox( "Name: gemUI" & vbCrLf & "Version: 1.0" & vbCrLf & "Build: 0001" & _
        vbCrLf & "(C) 2018 Josh Face", , "About gemUI")
End Sub

In VBA you call a subroutine with either

MySub arg1, arg2, arg3

or

Call MySub(arg1, arg2, arg3)

When you write

MySub (arg1, arg2, arg3)

it tries to combine the multiple arguments into one thing and it fails.

Upvotes: 3

Related Questions