First off i would like to say i am very new to vb, i am using vb 2008 express edition and while making a web browser (which is supposed to be one of the easiest things to do), i decided to some image links to some of my favorite sites, after putting the code where i wanted it ( <a href= blah blah blah) i got an expression expected at the end of the line (</a>) everything else is fine but this, can anyone advise me on how to correct it.

Dani AI

Generated

Summary: reported an "Expression expected" error after inserting HTML anchor markup while building a VB 2008 project. That compiler message usually means the VB parser found raw markup or malformed text where it expected a VB expression — most often because the HTML was placed into code without being a proper string literal, or internal quotes were not escaped.

Common fixes and examples:

  • Put HTML in the .aspx markup (outside server-side code) instead of inside the .vb code file.
  • If assigning HTML to a control from code-behind, make it a proper VB string and escape embedded double quotes (or use single quotes inside the HTML attribute).
  • Prefer server controls (HyperLink) when building links from code, rather than concatenating raw HTML.

Example (code-behind string assignment):

Label1.Text = "<a href=""</a>"

Alternative using single quotes inside the HTML attribute:

Label1.Text = "<a href='</a>"

Or use a server control on the .aspx page (recommended for Web Forms):

<asp:HyperLink ID="hlSite" runat="server" NavigateUrl="</asp:HyperLink>

Troubleshooting checklist:

  • If the error marker sits at the closing tag, look earlier on the same line for a missing opening quote or an unescaped quote.
  • Watch for improper concatenation: VB uses & (or +) and requires line-continuation with _ if splitting strings across lines.
  • Confirm the code is in the correct file type: raw HTML belongs in .aspx, not inside a .vb method unless wrapped as a string.
  • For web controls and properties, consult the control docs rather than injecting HTML manually.

References: Visual Basic string literal rules and escaping are documented on Microsoft Docs (). For building links in Web Forms see the HyperLink control documentation (HyperLink class).

Recommended Answers

All 2 Replies

Post the section of code where you are having problems.

i got it sorted eventually, thanks for the reply anyway

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.