A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Line Continuation issue



 
 
Thread Tools Display Modes
  #1  
Old May 21st, 2009, 01:37 PM posted to microsoft.public.excel.worksheet.functions
bishop
external usenet poster
 
Posts: 48
Default Line Continuation issue

What am I doing wrong? Here is the line of code:

Msg = MsgBox("You have "" "" PFs loaded in the Tally Sheet. Have you
completed "" ""PFs?", vbYesNo, "Completed PFs")

But I want to use ' _' to continue the phrase on the next line but when I do
this:

Msg = MsgBox("You have "" "" PFs loaded in the Tally Sheet. _
Have you completed "" ""PFs?", vbYesNo, "Completed PFs")

I keep getting "Expected: list separator or )"
  #2  
Old May 21st, 2009, 01:44 PM posted to microsoft.public.excel.worksheet.functions
Jacob Skaria
external usenet poster
 
Posts: 5,952
Default Line Continuation issue

Msg = MsgBox("You have "" "" PFs loaded in the Tally Sheet." & _
"Have you completed "" ""PFs?", vbYesNo, "Completed PFs")
--
If this post helps click Yes
---------------
Jacob Skaria


"Bishop" wrote:

What am I doing wrong? Here is the line of code:

Msg = MsgBox("You have "" "" PFs loaded in the Tally Sheet. Have you
completed "" ""PFs?", vbYesNo, "Completed PFs")

But I want to use ' _' to continue the phrase on the next line but when I do
this:

Msg = MsgBox("You have "" "" PFs loaded in the Tally Sheet. _
Have you completed "" ""PFs?", vbYesNo, "Completed PFs")

I keep getting "Expected: list separator or )"

  #3  
Old May 21st, 2009, 01:47 PM posted to microsoft.public.excel.worksheet.functions
Jarek Kujawa[_2_]
external usenet poster
 
Posts: 775
Default Line Continuation issue

use

Msg = MsgBox("You have "" "" PFs loaded in the Tally Sheet." &
vbNewLine & "Have you completed "" ""PFs?", vbYesNo, "Completed PFs")

On 21 Maj, 14:37, Bishop wrote:
What am I doing wrong? *Here is the line of code:

Msg = MsgBox("You have "" "" PFs loaded in the Tally Sheet. Have you
completed "" ""PFs?", vbYesNo, "Completed PFs")

But I want to use ' _' to continue the phrase on the next line but when I do
this:

Msg = MsgBox("You have "" "" PFs loaded in the Tally Sheet. *_
Have you completed "" ""PFs?", vbYesNo, "Completed PFs")

I keep getting "Expected: list separator or )"


  #4  
Old May 21st, 2009, 02:05 PM posted to microsoft.public.excel.worksheet.functions
Don Guillett
external usenet poster
 
Posts: 6,167
Default Line Continuation issue

prompt Required. String expression displayed as the message in the
dialog box. The maximum length of prompt is approximately 1024 characters,
depending on the width of the characters used. If prompt consists of more
than one line, you can separate the lines using a carriage return character
(Chr(13)), a linefeed character (Chr(10)), or carriage return – linefeed
character combination (Chr(13) & Chr(10)) between each line.

Msg = MsgBox("You have "" "" PFs loaded in the Tally Sheet." _
& Chr(10) & _
"Have you completed "" ""PFs?", vbYesNo, "Completed PFs")
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Jacob Skaria" wrote in message
news
Msg = MsgBox("You have "" "" PFs loaded in the Tally Sheet." & _
"Have you completed "" ""PFs?", vbYesNo, "Completed PFs")
--
If this post helps click Yes
---------------
Jacob Skaria


"Bishop" wrote:

What am I doing wrong? Here is the line of code:

Msg = MsgBox("You have "" "" PFs loaded in the Tally Sheet. Have you
completed "" ""PFs?", vbYesNo, "Completed PFs")

But I want to use ' _' to continue the phrase on the next line but when I
do
this:

Msg = MsgBox("You have "" "" PFs loaded in the Tally Sheet. _
Have you completed "" ""PFs?", vbYesNo, "Completed PFs")

I keep getting "Expected: list separator or )"


  #5  
Old May 21st, 2009, 02:12 PM posted to microsoft.public.excel.worksheet.functions
Jacob Skaria
external usenet poster
 
Posts: 5,952
Default Line Continuation issue

Oops..Use Vbcr Or VbLF for carriage return

Msg = MsgBox("You have "" "" PFs loaded in the Tally Sheet." & vbCrLf & _
"Have you completed "" ""PFs?", vbYesNo, "Completed PFs")

If this post helps click Yes
---------------
Jacob Skaria


"Bishop" wrote:

What am I doing wrong? Here is the line of code:

Msg = MsgBox("You have "" "" PFs loaded in the Tally Sheet. Have you
completed "" ""PFs?", vbYesNo, "Completed PFs")

But I want to use ' _' to continue the phrase on the next line but when I do
this:

Msg = MsgBox("You have "" "" PFs loaded in the Tally Sheet. _
Have you completed "" ""PFs?", vbYesNo, "Completed PFs")

I keep getting "Expected: list separator or )"

  #6  
Old May 21st, 2009, 02:18 PM posted to microsoft.public.excel.worksheet.functions
Jacob Skaria
external usenet poster
 
Posts: 5,952
Default Line Continuation issue

Dear Bishop

A small suggestion. When you have bigger text to be displayed use a variable
to build the message before display..something like..the below

Dim intCount As Integer
Dim strMsg As String

strMsg = "You have " & intCount & " PFs loaded in the Tally Sheet."
strMsg = strMsg & vbCrLf & vbCrLf & " Have you completed " & intCount & "
PFs?"

If MsgBox(strMsg, vbYesNo + vbDefaultButton2, " Completed PFs") vbYes _
Then Exit Sub


If this post helps click Yes
---------------
Jacob Skaria


"Jacob Skaria" wrote:

Oops..Use Vbcr Or VbLF for carriage return

Msg = MsgBox("You have "" "" PFs loaded in the Tally Sheet." & vbCrLf & _
"Have you completed "" ""PFs?", vbYesNo, "Completed PFs")

If this post helps click Yes
---------------
Jacob Skaria


"Bishop" wrote:

What am I doing wrong? Here is the line of code:

Msg = MsgBox("You have "" "" PFs loaded in the Tally Sheet. Have you
completed "" ""PFs?", vbYesNo, "Completed PFs")

But I want to use ' _' to continue the phrase on the next line but when I do
this:

Msg = MsgBox("You have "" "" PFs loaded in the Tally Sheet. _
Have you completed "" ""PFs?", vbYesNo, "Completed PFs")

I keep getting "Expected: list separator or )"

  #7  
Old May 21st, 2009, 03:07 PM posted to microsoft.public.excel.worksheet.functions
Rick Rothstein[_2_]
external usenet poster
 
Posts: 2,013
Default Line Continuation issue

Text strings constants (which are defined by a starting and ending quote
mark) must all appear on the same line. When you put your line continuation
character in, you left the quote marks unbalanced on the original line (no
ending quote mark) and on the newly created line (no starting quote mark).
You *cannot* simply put them in like this though...

Msg = MsgBox("You have "" "" PFs loaded in the Tally Sheet." _
"Have you completed "" ""PFs?", vbYesNo, "Completed PFs")

because VB will not know what to do with the two parts. It would be like if
you wrote this line of code...

StrVar = "First part of sentence" "Next part of sentence"

To handle both of these, you would need an ampersand between the two text
string constants in order to concatenate them together. So, your original
line line of code could have been written this way...

Msg = MsgBox("You have "" "" PFs loaded in the Tally Sheet. " & _
"Have you completed "" ""PFs?", vbYesNo, "Completed PFs")

Doing it this way, however, will just link the two text string constants
together as if they had been written in a single line. You would do it this
way in order to "neaten" up your code on the screen in order that *you*
could more read it more easily (as opposed to having a long text string
possibly trail off the screen because it is too long to display within the
given the code window's width. To do what I think you asked... display the
two individual text string constants on two separate lines within the
MessageBox... you have to tell VB to put a line separating character between
them. The help files say that you can use a Line Feed character, a Carriage
Return or a combination of Line Feed and Carriage Return characters (in that
order). VB has predefined characters for these line separating characters
and they are, in the same order I listed them in, vbLf, vbCr and vbLfCr. VB
also has an alternative constant for that last one... vbNewLine. So, using
vbLf as the separator, your original code line would be...

Msg = MsgBox("You have "" "" PFs loaded in the Tally Sheet." & vbLf & _
"Have you completed "" ""PFs?", vbYesNo, "Completed PFs")

Now, when VB creates the MessageBox message, it will display the two text
string constants on separate lines.

--
Rick (MVP - Excel)


"Bishop" wrote in message
...
What am I doing wrong? Here is the line of code:

Msg = MsgBox("You have "" "" PFs loaded in the Tally Sheet. Have you
completed "" ""PFs?", vbYesNo, "Completed PFs")

But I want to use ' _' to continue the phrase on the next line but when I
do
this:

Msg = MsgBox("You have "" "" PFs loaded in the Tally Sheet. _
Have you completed "" ""PFs?", vbYesNo, "Completed PFs")

I keep getting "Expected: list separator or )"


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:28 PM.


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