eugeneK
eugeneK

Reputation: 11116

Error 2 'If', 'ElseIf', 'Else', 'End If', 'Const', or 'Region' expected

I've made some function that generates an email template. Code it generates is pure HTML with CSS. Problem is compiler does this odd error and highlights each time '#' sign appears which is needed to define colors in CSS. I did try to change '#' to '/pound/' and then string.Replace() on RETURN but no luck. I'm more into C# so there i can escape special characters by using '\' before them but something f$#$ed up there... Once i remove '#' all back to normal and compiles well. Any guesses ?

btw, i'm using StringBuilder to generate lines of code with sb.Append().

ie.

sb.Append("<div style=""color:#333"">some text</div>")

Upvotes: 0

Views: 1843

Answers (2)

Keith
Keith

Reputation: 5381

I was receiving this same exact error and was able to simply copy the line, delete the line out, re-add a new line, and paste.

Upvotes: 1

manji
manji

Reputation: 47978

I think it's a bug,

to reproduce it I used VB.NET 2 (VS 2005), I wrote your instruction:

sb.Append("<div style=""color:#333"">some text</div>")

no problem,

I added some extra " to have the error message you got, I then fixed everything, all errors disappeared except yours.

Solution: Delete that line, error disappeared, ctrl-z (undo) --> all ok!

Upvotes: 1

Related Questions