Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default MsgBox problem

I have a problem with the following code:

Private Sub CommandButton2_Click()
Msg = "In Service Settings select Bone Fluoro." & Chr(13) & _
"If value of Filter NR 1 on Dose 1 tab is 6, " & _
"set MTS=2.16 otherwise set MTS=2.15"
Style = vbOKOnly
Title = "Which MTS table?"
MsgBox (Msg, Style, Title)
End Sub

With the MsgBox line, if I only specify Msg, everything is OK. If I try to
specify any other parameter, I get a compile error stating that and equals
sign is expected.

I've tried MsgBox(Msg, , Title) as well, but with no change.
I've also tried MsgBox("Msg", , "Title") and MsgBox(Msg, vbOKOnly, Title). I
know this wouldn't show the message & title I need, but I wondered if there
was some problem with my actual message to cause this problem.

I could incorporate the title text within the message, but that defeats the
object of the function allowing a title to be specified.

Any ideas why this isn't working? As far as I can tell from VBA Help there
are no errors in my syntax, but as usual I could be wrong!

--
Ian
--


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 143
Default MsgBox problem

On Sep 16, 6:36*am, "IanC" wrote:
I have a problem with the following code:

Private Sub CommandButton2_Click()
Msg = "In Service Settings select Bone Fluoro." & Chr(13) & _
* * "If value of Filter NR 1 on Dose 1 tab is 6, " & _
* * "set MTS=2.16 otherwise set MTS=2.15"
Style = vbOKOnly
Title = "Which MTS table?"
MsgBox (Msg, Style, Title)
End Sub

With the MsgBox line, if I only specify Msg, everything is OK. If I try to
specify any other parameter, I get a compile error stating that and equals
sign is expected.

I've tried MsgBox(Msg, , Title) as well, but with no change.
I've also tried MsgBox("Msg", , "Title") and MsgBox(Msg, vbOKOnly, Title).. I
know this wouldn't show the message & title I need, but I wondered if there
was some problem with my actual message to cause this problem.

I could incorporate the title text within the message, but that defeats the
object of the function allowing a title to be specified.

Any ideas why this isn't working? As far as I can tell from VBA Help there
are no errors in my syntax, but as usual I could be wrong!

--
Ian
--


Hi Ian:

In this case MsgBox needs a place for the retrun:


Sub one()
Dim ret
msg = "In Service Settings select Bone Fluoro." & Chr(13) & _
"If value of Filter NR 1 on Dose 1 tab is 6, " & _
"set MTS=2.16 otherwise set MTS=2.15"
Style = vbOKOnly
title = "Which MTS table?"
ret = MsgBox(msg, Style, title)
End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default MsgBox problem

Hi
Unless you are trying to capture the value of the MsgBox use
MsgBox Msg, Style, Title

with no brackets.
If you want to store the return value in a variable use

MyValue = MsgBox(Msg, Style, Title)

regards
Paul



On Sep 16, 11:36*am, "IanC" wrote:
I have a problem with the following code:

Private Sub CommandButton2_Click()
Msg = "In Service Settings select Bone Fluoro." & Chr(13) & _
* * "If value of Filter NR 1 on Dose 1 tab is 6, " & _
* * "set MTS=2.16 otherwise set MTS=2.15"
Style = vbOKOnly
Title = "Which MTS table?"
MsgBox (Msg, Style, Title)
End Sub

With the MsgBox line, if I only specify Msg, everything is OK. If I try to
specify any other parameter, I get a compile error stating that and equals
sign is expected.

I've tried MsgBox(Msg, , Title) as well, but with no change.
I've also tried MsgBox("Msg", , "Title") and MsgBox(Msg, vbOKOnly, Title).. I
know this wouldn't show the message & title I need, but I wondered if there
was some problem with my actual message to cause this problem.

I could incorporate the title text within the message, but that defeats the
object of the function allowing a title to be specified.

Any ideas why this isn't working? As far as I can tell from VBA Help there
are no errors in my syntax, but as usual I could be wrong!

--
Ian
--


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default MsgBox problem

Thanks Paul & James.

It looks like this is one of those Excel oddities. It's odd that it will
work as I had it with just the message, but not when trying to specify a
title as well.

Both your solutions work and I've opted for the non-bracketed approach.

--
Ian
--

"Paul Robinson" wrote in message
...
Hi
Unless you are trying to capture the value of the MsgBox use
MsgBox Msg, Style, Title

with no brackets.
If you want to store the return value in a variable use

MyValue = MsgBox(Msg, Style, Title)

regards
Paul



On Sep 16, 11:36 am, "IanC" wrote:
I have a problem with the following code:

Private Sub CommandButton2_Click()
Msg = "In Service Settings select Bone Fluoro." & Chr(13) & _
"If value of Filter NR 1 on Dose 1 tab is 6, " & _
"set MTS=2.16 otherwise set MTS=2.15"
Style = vbOKOnly
Title = "Which MTS table?"
MsgBox (Msg, Style, Title)
End Sub

With the MsgBox line, if I only specify Msg, everything is OK. If I try to
specify any other parameter, I get a compile error stating that and equals
sign is expected.

I've tried MsgBox(Msg, , Title) as well, but with no change.
I've also tried MsgBox("Msg", , "Title") and MsgBox(Msg, vbOKOnly, Title).
I
know this wouldn't show the message & title I need, but I wondered if
there
was some problem with my actual message to cause this problem.

I could incorporate the title text within the message, but that defeats
the
object of the function allowing a title to be specified.

Any ideas why this isn't working? As far as I can tell from VBA Help there
are no errors in my syntax, but as usual I could be wrong!

--
Ian
--




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
msgBox problem Jeff Ciaccio Excel Programming 3 June 12th 08 10:35 PM
Problem in Msgbox() ashish128 Excel Discussion (Misc queries) 4 August 30th 07 04:19 PM
MsgBox Problem Rob Excel Programming 4 September 9th 06 01:39 AM
Problem with coding a msgbox Jacqui Excel Programming 5 November 2nd 05 04:36 PM
Problem with array and msgbox aking1987 Excel Worksheet Functions 1 October 29th 04 01:57 PM


All times are GMT +1. The time now is 10:22 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"