我是VBA和html的新手,我很困惑。
我正在尝试将字符串变量设置为等于几个连接的html字符串和控件值。我无法弄清楚我做错了什么。
这是我的代码:
htmlText = "<HTML><BODY bgcolor=#0b3767> <img height=""71"" width=""500"" alt=""Central Analysis Bureau, Inc. - Know Your Insureds"" src=""http://cabfinancial.com/images/logoEmail.png"">"_
& "<a href=" & txtLink.Value & ">Volume " & txtVolume.Value & " Edition " & txtEdition.Value _
& "</a>" _
& txtHtml.Value & "<a href=""txtLink.Value"">Click here to read the complete article</a>" _
& "</BODY></HTML>"
htmlText是一个字符串。 txtLink,txtVolume,txtEdition,txtHtml都是表单上的文本框控件。
答案 0 :(得分:2)
行继续语法在下划线之前需要一个空格。尝试在第一行的末尾添加一个空格:
src=""http://cabfinancial.com/images/logoEmail.png"">"_
变为
src=""http://cabfinancial.com/images/logoEmail.png"">" _
答案 1 :(得分:0)
htmlText = "<HTML><BODY bgcolor='#0b3767'> <img height='71' width='500' alt='Central Analysis Bureau, Inc. - Know Your Insureds' src='http://cabfinancial.com/images/logoEmail.png'>" _ & "<a href='" & txtLink.Value & "'>Volume " & txtVolume.Value & " Edition " & txtEdition.Value _ & "</a>" _ & txtHtml.Value & "<a href='" & txtLink.Value & "'>Click here to read the complete article</a>" _ & "</BODY></HTML>"
答案 2 :(得分:0)
我在bgcolor参数周围添加了双引号,在第一行续行字符前添加了一个空格,在&lt; a href = txtLink.Value&gt;
周围添加了双引号和&符号顺便说一句:赞美使用&符号进行连接。有些人使用+有效,但令人困惑。
htmlText = "<HTML><BODY bgcolor=""#0b3767""><img height=""71"" width=""500"" alt=""Central Analysis Bureau, Inc. - Know Your Insureds"" src=""http://cabfinancial.com/images/logoEmail.png"">" _
& "<a href=" & txtLink.Value & ">Volume " & txtVolume.Value & " Edition " & txtEdition.Value _
& "</a>" _
& txtHtml.Value & "<a href=""" & txtLink.Value & """>Click here to read the complete article</a>" _
& "</BODY></HTML>"