#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default MsgBox Help

Hi all need some help I have got message box the code for the box is

MsgBox (Sheet2.Range("a2").Value & " has the most Expensive Phone to buy
Initially")

And I want to add a Vbokonly and vbinformation to it so it only display a ok
button and the information image.
(vbOKOnly + vbInformation)

The code I thought would be somthing like this.
MsgBox (Sheet2.Range("a2").Value & " has the most Expensive Phone to buy
Initially",vbOKOnly + vbInformation)

But this is not working so any help or advice thanks all :)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default MsgBox Help



"millwalll" wrote:

Hi all need some help I have got message box the code for the box is

MsgBox (Sheet2.Range("a2").Value & " has the most Expensive Phone to buy
Initially")

And I want to add a Vbokonly and vbinformation to it so it only display a ok
button and the information image.
(vbOKOnly + vbInformation)

The code I thought would be somthing like this.
MsgBox (Sheet2.Range("a2").Value & " has the most Expensive Phone to buy
Initially",vbOKOnly + vbInformation)

But this is not working so any help or advice thanks all :)


p.s is there way to change the msgbox name at mins is says microsoft excel ??
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default MsgBox Help

MsgBox Prompt:=Sheet2.Range("a2").Value _
& " has the most Expensive Phone to buy Initially", _
buttons:=vbOKOnly + vbInformation, _
title:="what's the title"

Check VBA's help for more options.

ps. If you want to add a new line:

MsgBox Prompt:=Sheet2.Range("a2").Value & vbnewline _
& " has the most Expensive Phone to buy Initially", _
buttons:=vbOKOnly + vbInformation, _
title:="what's the title"


millwalll wrote:

Hi all need some help I have got message box the code for the box is

MsgBox (Sheet2.Range("a2").Value & " has the most Expensive Phone to buy
Initially")

And I want to add a Vbokonly and vbinformation to it so it only display a ok
button and the information image.
(vbOKOnly + vbInformation)

The code I thought would be somthing like this.
MsgBox (Sheet2.Range("a2").Value & " has the most Expensive Phone to buy
Initially",vbOKOnly + vbInformation)

But this is not working so any help or advice thanks all :)


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default MsgBox Help

On 14 Dec., 01:13, millwalll
wrote:
Hi all need some help I have got message box the code for the box is

MsgBox (Sheet2.Range("a2").Value & " has the most Expensive Phone to buy
Initially")

And I want to add a Vbokonly and vbinformation to it so it only display a ok
button and the information image.
(vbOKOnly + vbInformation)

The code I thought would be somthing like this.
MsgBox (Sheet2.Range("a2").Value & " has the most Expensive Phone to buy
Initially",vbOKOnly + vbInformation)

But this is not working so any help or advice thanks all :)


msg = MsgBox(Sheet2.Range("a2").Value & " has the most Expensive Phone
to buy Initially ", vbOKOnly + vbInformation)
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 284
Default MsgBox Help

MsgBox Sheet2.Range("A2").Value _
& " has the most Expensive Phone to buy Initially", 64, "Cool Title"


Steve Yandl



"millwalll" wrote in message
...
Hi all need some help I have got message box the code for the box is

MsgBox (Sheet2.Range("a2").Value & " has the most Expensive Phone to buy
Initially")

And I want to add a Vbokonly and vbinformation to it so it only display a
ok
button and the information image.
(vbOKOnly + vbInformation)

The code I thought would be somthing like this.
MsgBox (Sheet2.Range("a2").Value & " has the most Expensive Phone to buy
Initially",vbOKOnly + vbInformation)

But this is not working so any help or advice thanks all :)





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default MsgBox Help

Hi all need some help I have got message box the code for the box is

MsgBox (Sheet2.Range("a2").Value & " has the most Expensive Phone to buy
Initially")

And I want to add a Vbokonly and vbinformation to it so it only display a
ok
button and the information image.
(vbOKOnly + vbInformation)

The code I thought would be somthing like this.
MsgBox (Sheet2.Range("a2").Value & " has the most Expensive Phone to buy
Initially",vbOKOnly + vbInformation)

But this is not working so any help or advice thanks all :)


As others have shown without specifically pointing to the reason, your
problem stems from the parentheses. MsgBox is a function and when used to
return a value, such as like this...

Answer = MsgBox("Here is a question", vbYesNo Or vbQuestion)

the parentheses are required. When no value is returned, the function
effectively becomes a subroutine. There are two proper ways to call a
subroutine...

Call MsgBox("Here is a question", vbYesNo Or vbQuestion)

and

MsgBox "Here is a question", vbYesNo Or vbQuestion

Note that when Call is used, the parentheses are required; however, when the
Call keyword is omitted, the parentheses are syntactically incorrect. So you
are probably asking, "Why did it work when I didn't add the 2nd argument?"
Good question. It seems that when parentheses are used in a statement that
are not required by syntax, VB assumes it has an expression to evaluate and,
well, it attempts to evaluate the contents of the parentheses. When you
specified only a single text argument, VB could evaluate it... it simply
evaluates as itself. But, when you added the 2nd argument, VB has no
mechanism to evaluate two expressions without an operator of some kind
between them (the comma is not an expression operator), so it generated an
error. The bottom line is to use parentheses in a subroutine statement
**only** when they are required by syntax (do not use them to "pretty"
things up as doing that will create problems in more situations than the one
I just outlined).

Rick

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default MsgBox Help



"Rick Rothstein (MVP - VB)" wrote:

Hi all need some help I have got message box the code for the box is

MsgBox (Sheet2.Range("a2").Value & " has the most Expensive Phone to buy
Initially")

And I want to add a Vbokonly and vbinformation to it so it only display a
ok
button and the information image.
(vbOKOnly + vbInformation)

The code I thought would be somthing like this.
MsgBox (Sheet2.Range("a2").Value & " has the most Expensive Phone to buy
Initially",vbOKOnly + vbInformation)

But this is not working so any help or advice thanks all :)


As others have shown without specifically pointing to the reason, your
problem stems from the parentheses. MsgBox is a function and when used to
return a value, such as like this...

Answer = MsgBox("Here is a question", vbYesNo Or vbQuestion)

the parentheses are required. When no value is returned, the function
effectively becomes a subroutine. There are two proper ways to call a
subroutine...

Call MsgBox("Here is a question", vbYesNo Or vbQuestion)

and

MsgBox "Here is a question", vbYesNo Or vbQuestion

Note that when Call is used, the parentheses are required; however, when the
Call keyword is omitted, the parentheses are syntactically incorrect. So you
are probably asking, "Why did it work when I didn't add the 2nd argument?"
Good question. It seems that when parentheses are used in a statement that
are not required by syntax, VB assumes it has an expression to evaluate and,
well, it attempts to evaluate the contents of the parentheses. When you
specified only a single text argument, VB could evaluate it... it simply
evaluates as itself. But, when you added the 2nd argument, VB has no
mechanism to evaluate two expressions without an operator of some kind
between them (the comma is not an expression operator), so it generated an
error. The bottom line is to use parentheses in a subroutine statement
**only** when they are required by syntax (do not use them to "pretty"
things up as doing that will create problems in more situations than the one
I just outlined).

Rick

Thanks all :)

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
ABOUT MSGBOX Andy Excel Programming 3 July 25th 05 03:42 AM
msgbox Jo[_6_] Excel Programming 3 April 7th 04 12:15 AM
MsgBox Lawson Excel Programming 2 April 6th 04 02:58 PM
Msgbox Lawson Excel Programming 3 April 6th 04 12:15 AM
MsgBox redmad Excel Programming 1 August 1st 03 12:18 AM


All times are GMT +1. The time now is 05:06 AM.

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"