Sunday, March 20, 2011

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>")
From stackoverflow
  • 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!

    CodeByMoonlight : I replicated it once, quit VS, reloaded, the error didn't reappear and now I can't replicate it anymore.
    eugeneK : I think this is a bug as well. It happened to me while using code on page and writting js tags for scripts as strings. ie.
  • 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.

0 comments:

Post a Comment