I want to convert #C code language to VB.NET for javascript in code behind.

peter liles 556 Reputation points
2022-02-08T23:46:22.377+00:00

I have the following code that is written using #C language and i want to convert to VB instead. error message suggest the inner double quotes are wrong?

Dim JS As StringBuilder = New StringBuilder()
JS.Append("<script type=\"text/javascript\">\n");
JS.Append("pix = parseInt(objtbl.style.left.replace(\"px\",\"\"));\n");

    JS.Append("}\n");
Developer technologies ASP.NET Other
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Jose Zero 576 Reputation points
    2022-02-09T00:03:58.46+00:00

    Try this way, if necessary make proper adjustments at "replace" to give what you looking for

    Dim JS As StringBuilder = New StringBuilder()
        JS.Append("<script type=""text/javascript\"">")
        JS.Append("pix = parseInt(objtbl.style.left.replace(""px"",""))")
    
    0 comments No comments

  2. Yijing Sun-MSFT 7,096 Reputation points
    2022-02-09T07:46:54.66+00:00

    Hi @peter liles ,
    As far as I think,you could do like this:
    c#:

    js.Append("<script type=\"text/javascript\">");  
    js.Append("pix = parseInt(objtbl.style.left.replace('\"px\"', \"\"));");  
    js.Append("</script>");  
    

    vb:

    js.Append("<script type=""text/javascript"">")  
    js.Append("pix = parseInt(objtbl.style.left.replace('""px""', """"))")  
    js.Append("</script>")  
    

    Best regards,
    Yijing Sun


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our  documentation  to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.