help mixing varibles with html
Hi all i am trying to use the 3 varible call Line1,Line2,Line3 and keep getting syntax error . could you guys help me fix it .Thanks
Code:
Dim htm2 As String
html2 = "<li>" & _
"<a href=" "&sLine1& "">" & _
"<img src=""&sLine2& "" alt="" /><br />"&sLine3& "</a><br />" & _
"</li><li>"
RichTextBox1 = html2
Re: help mixing varibles with html
You say they are named Line1, Line2, Line3 but I only see you use sLine1 and sLine2.
Also, you need spaces before and after & when doing string concatenation. And when you want to use a quotes character inside a quoted string you have to double it. For example: MsgBox """" will only display: "
Try this corrected code:
Code:
html2 = "<li>" & _
"<a href=""" & sLine1 & """>" & _
"<img src=""" & sLine2 & """ alt="""" /><br />" & sLine1 & "</a><br />" & _
"</li><li>"
Re: help mixing varibles with html
Quote:
Originally Posted by
baja_yu
You say they are named Line1, Line2, Line3 but I only see you use sLine1 and sLine2.
Also, you need spaces before and after & when doing string concatenation. And when you want to use a quotes character inside a quoted string you have to double it. For example: MsgBox """" will only display: "
Try this corrected code:
Code:
html2 = "<li>" & _
"<a href=""" & sLine1 & """>" & _
"<img src=""" & sLine2 & """ alt="""" /><br />" & sLine1 & "</a><br />" & _
"</li><li>"
i edited my above post.how to use them inside such html ?
Re: help mixing varibles with html
Re: help mixing varibles with html
Thanks it worked but how to do like this adding http before sLine1?
Code:
"<a href="http://www.somesite.com/id="" & sLine1 & """>" & _
Re: help mixing varibles with html
Read what I said about using quotes in strings (within quotes)
if you want to write: <a href="http://www.somesite.com/id="
to a string you have to double up those qoutes, so it would look like
strA = "<a href=""http://www.somesite.com/id="""