View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz[_2_] JLGWhiz[_2_] is offline
external usenet poster
 
Posts: 1,565
Default Changing Meassage Box Title

If I was doing it, I would use the ComboBox click event. I would put this
code in the UserForm code module. In design mode, right click on the form
and select View Code. Paste this in the code window.


Private Sub Engineer_2_Click()
If Me.Engineer_2.ListIndex = - 1 Then
Exit Sub
Else
If Time < 0.5 Then
Msg = "Morning "
ElseIf Time < 0.75 Then
Msg = "Afternoon "
Else
Msg = "Evening "
End If
Msg = "Good " & Msg & Me.Engineer_2.Value
Msg = Msg & vbNewLine & vbNewLine
Msg = Msg & "Welcome to the C.E.S."
Titl = "C.E.S."
MsgBox Msg, , Titl
End If
End Sub


Now the code will run as soon as the user selects a name from the ComboBox.
If the ComboBox has no selection, then the message box does not display.
Notice also that the "e" was remove from the word "Title". That is because,
Title is a reserved word that is used in the parameters portion of the
message box and some other functions and methods such as InputBox. It is a
good practice to avoid using reserved words for variables that might have
different definitions and characteristics than those assigned in VBA source
code.

Have a good Christmas and New Year.



"Brian" wrote in message
...
I got it fixed,

Thanks for all your help & Have a Merry Christmas!!

"JLGWhiz" wrote:

Just for clarification:

The message box has three elements:
1. The message must be a string or a string variable. Strings are
enclosed
in quoteation marks, but the string variables are not.

2. Buttons and icons. These are optional items but the default is vbOK
which puts a button with the caption "OK" on the message box display.

3. The title must be a string or string variable.

When using the message box as an information medium only, you do not use
the
parenthesies or equal sign. However when using the message box as a
function, you must assign a variable and use the equal sign and then the
parentheses to enclose the three elements.

I hope this helps rather than confuses.


"Brian" wrote in message
...
I have a message box that I would like to change the title of. Right now
it
say's Microsoft Excel

Here is the code I have, but I am missing something. According to the
book
I
have this should work.

'Greeting Message Bob
Dim Title As String

If Me.Engineer_2.Value = "Bozeman" Then
If Time < 0.5 Then
Msg = "Morning "
ElseIf Time < 0.75 Then
Msg = "Afternoon "
Else
Msg = "Evening "
End If

Msg = "Good " & Msg & "Mr. Bozeman"
Msg = Msg & vbNewLine & vbNewLine
Msg = Msg & "Welcome to the C.E.S."
MsgBox Msg

Title = "C.E.S."

End If

Any ideas?



.