Here is my problem:

I have this line:
strEmailBody="Your machine PC has failed to backup one or more of the
requested files. To verify which files have been backed up visit <\
\fileserver\Fileserver\Cell Folders\Backups>. We recommend that you
figure out the cause of this issue and fix it or contact Information
Technology if you need assistance. Failure to do so might put you at
risk of losing critical data. If you have any questions or if you feel
that the information provided is not correct, please contact it.help.
Thank you for your time, IT Team."

I want to include the source in there which is a variable based on
what is being backed up. I can put &source at the end of that and it
shows up, however when I try to add it somewhere in the middle it only
shows up as &source and not the actual source.

I closing the quotes before &source and then creating new one
afterwards like so:
strEmailBody="Your machine PC has failed to backup one or more of the
requested files. To verify which files have been backed up visit <\
\fileserver\Fileserver\Cell Folders\Backups>. We recommend that you
figure out the cause of this issue and fix it or contact Information
Technology if you need assistance. " &source " Failure to do so might
put you at risk of losing critical data. If you have any questions or
if you feel that the information provided is not correct, please
contact it.help. Thank you for your time, IT Team."

but that gives me an error:
expected end of statement

How do I add in there?
Thanks!

Re: variable within text by Anthony

Anthony
Thu Jul 19 09:35:55 CDT 2007


"yosseeppii" <yosseeppii@gmail.com> wrote in message
news:1184854636.106800.124980@g12g2000prg.googlegroups.com...
> Here is my problem:
>
> I have this line:
> strEmailBody="Your machine PC has failed to backup one or more of the
> requested files. To verify which files have been backed up visit <\
> \fileserver\Fileserver\Cell Folders\Backups>. We recommend that you
> figure out the cause of this issue and fix it or contact Information
> Technology if you need assistance. Failure to do so might put you at
> risk of losing critical data. If you have any questions or if you feel
> that the information provided is not correct, please contact it.help.
> Thank you for your time, IT Team."
>
> I want to include the source in there which is a variable based on
> what is being backed up. I can put &source at the end of that and it
> shows up, however when I try to add it somewhere in the middle it only
> shows up as &source and not the actual source.
>
> I closing the quotes before &source and then creating new one
> afterwards like so:
> strEmailBody="Your machine PC has failed to backup one or more of the
> requested files. To verify which files have been backed up visit <\
> \fileserver\Fileserver\Cell Folders\Backups>. We recommend that you
> figure out the cause of this issue and fix it or contact Information
> Technology if you need assistance. " &source " Failure to do so might
> put you at risk of losing critical data. If you have any questions or
> if you feel that the information provided is not correct, please
> contact it.help. Thank you for your time, IT Team."
>
> but that gives me an error:
> expected end of statement
>

& is an operator

src = "B"
dest = "A" & B & "C"

The value of dest will be "ABC".

Note this is useful in breaking up text across lines in combination with the
line continuation character _ :-

strEmailBody = "Your machine PC has failed to backup" & _
" one or more of the requested files. To verify which files" & _
" have been backed up visit " & _
"<\\fileserver\Fileserver\Cell Folders\Backups>." & vbCrLf & _
" We recommend that you figure out the cause of this issue" & _
" and fix it or contact Information Technology if you need" & _
" assistance. " & source & " Failure to do so might" & _
" put you at risk of losing critical data. If you have any" & _
" questions or if you feel that the information provided" & _
" is not correct, please contact it.help. " & vbCrLf & _
"Thank you for your time, IT Team."

Note the use of vbCrLf to add carriage returns and line feeds.


--
Anthony Jones - MVP ASP/ASP.NET



Re: variable within text by Bob

Bob
Thu Jul 19 09:47:12 CDT 2007

yosseeppii wrote:
> strEmailBody="Your machine PC has failed to backup one or more of the
> requested files. To verify which files have been backed up visit <\
> \fileserver\Fileserver\Cell Folders\Backups>. We recommend that you
> figure out the cause of this issue and fix it or contact Information
> Technology if you need assistance. " &source " Failure to do so might
> put you at risk of losing critical data. If you have any questions or
> if you feel that the information provided is not correct, please
> contact it.help. Thank you for your time, IT Team."
>
> but that gives me an error:
> expected end of statement
>
"concatenation" is the act of appending one string to another,
combining them to make a new string.

& is a concatenation operator, and is placed between the two operands,
i.e., the two strings being combined.

When appending one string to another, a single concatenation is done, so
only one & is needed. In your expression above, you have 3 string
expressions:

1. "Your machine PC has failed to backup one or more of the
requested files. To verify which files have been backed up visit <\
\fileserver\Fileserver\Cell Folders\Backups>. We recommend that you
figure out the cause of this issue and fix it or contact Information
Technology if you need assistance. "

2. source

3. " Failure to do so might
put you at risk of losing critical data. If you have any questions or
if you feel that the information provided is not correct, please
contact it.help. Thank you for your time, IT Team."

Doesn't it seem logical that you need two concatenation operators for
this? Would you try to add three numbers, say: 1,2 and 3, by writing:
1+23 ?

No, you need two addition operators, one between each of the addends:
1 + 2 + 3

The same applies to your task:

strEmailBody="Your machine PC ... assistance. " & _
source & " Failure ... IT Team."

Bob Barrows


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.