Search code examples
c#vb.netvisual-studio-2010visual-studio-2012code-conversion

after converting c# to vb.net there is an error Syntax error ,Identifier expected,etc


is there a best code solution so that there is no error in the vb.net?. is there a possibility of an error in the conversion? I provide a share link because I failed continuously to post the code c #.

LINK GOOGLE DRIVE CODE C#

'code output in VB.NET
Private Shared Function GenerateReceiptTemplate() As String
            Return "
                <center>
                    <font size='24px'><b>WcDonalds</b></font><br/> ''>' expected
                    <span>wcdonalds@gmail.com</span> 'Attribute specifier is not a complete statement. Use a line continuation to apply the attribute to the following statement.
                </center> 'Identifier expected
                <br/><br/> ''>' expected
                <table width='100%'> ''>' expected
                    <thead>
                        <tr>
                            <th align='left'>Product Name</th> ''>' expected
                            <th>Quantity</th> 'Attribute specifier is not a complete statement. Use a line continuation to apply the attribute to the following statement.
                            <th align='right'>Subtotal</th> ''>' expected
                        </tr> 'Identifier expected
                    </thead> 'Identifier expected
                    <tbody>
                        <Orders/> ''>' expected
                    </tbody> 'Identifier expected
                </table> 'Identifier expected
                <br/> ''>' expected
                <center>---------------------------------------</center> 'Attribute specifier is not a complete statement. Use a line continuation to apply the attribute to the following statement.
                <br/> ''>' expected

                Total: <b><Total/></b><br/> ''>' expected
                Cash: <b><Cash/></b><br/> ''>' expected
                Change: <b><Change/></b><br/> ''>' expected
                <br/> ''>' expected
                Transaction ID: #<Id/><br/> 'Syntax error & Method arguments must be enclosed in parentheses & 'Transaction' is a type and cannot be used as an expression & 'If', 'ElseIf', 'Else', 'End If', 'Const', or 'Region' expected & 'ID' is not declared. It may be inaccessible due to its protection level
                Cashier: <Cashier/><br/> ''>' expected
                Date: <Date/><br/> 'Keyword is not valid as an identifier & 'Date' is a type and cannot be used as an expression & '.' expected

                <br/> ''>' expected
                <center>---------------------------------------</center> 'Attribute specifier is not a complete statement. Use a line continuation to apply the attribute to the following statement.
                <br/> ''>' expected

                <center><b>Thanks for visiting WcDonalds</b></center> 'Attribute specifier is not a complete statement. Use a line continuation to apply the attribute to the following statement.
                " 'Syntax error
        End Function

thanks jack


Solution

  • In code editor you can use the HTML language, just enter the start tag
    of an element like the root <html>, hit Enter and the editor will append the end tag </html> for you. You can then call </html>.ToString() to return the HTML block as string.

    In the GenerateReceiptTemplate function, replace everything with:

    Private Shared Function GenerateReceiptTemplate() As String
        Return <html>
    
                </html>.ToString()
    End Function
    

    From the file, Copy the HTML between the two double quotes "..." and paste it in the <html></html> block.

    Private Shared Function GenerateReceiptTemplate() As String
        Return <html>
                    <center>
                        <font size='24px'><b>WcDonalds</b></font><br/>
                        <span>wcdonalds@gmail.com</span>
                    </center>
                    <br/><br/>
                    <table width='100%'>
                        <thead>
                            <tr>
                                <th align='left'>Product Name</th>
                                <th align='center'>Quantity</th>
                                <th align='right'>Subtotal</th>
                            </tr>
                        </thead>
                        <tbody>
                            <Orders/>
                        </tbody>
                    </table>
                    <br/>
                    <center>---------------------------------------</center>
                    <br/>
    
            Total: <b><Total/></b><%= qty %><br/>
            Cash: <b><Cash/></b><%= someSharedField %><br/>
            Change: <b><Change/></b><%= someParam %><br/>
                    <br/>
            Transaction ID:   #<Id/><br/>
            Cashier: <Cashier/><br/>
            Date: <Date/><br/>
    
                    <br/>
                    <center>---------------------------------------</center>
                    <br/>
    
                    <center><b>Thanks For visiting WcDonalds</b></center>
                </html>.ToString()
    End Function
    

    That's it all.

    Note: Not sure whether VS2010, VS2012 frameworks support this feature. Time to move on!