簡體   English   中英

將 c# 轉換為 vb.net 后出現錯誤語法錯誤、預期標識符等

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

是否有最好的代碼解決方案,以便在 vb.net 中沒有錯誤? 轉換中是否有可能出錯? 我提供了一個分享鏈接,因為我一直未能發布代碼 c#。

鏈接 GOOGLE 驅動器代碼 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

謝謝傑克

代碼編輯器中可以使用 HTML 語言,只需輸入開始標記
對於像根<html>這樣的元素,按 Enter 鍵,編輯器將為您附加結束標記</html> 然后,您可以調用</html>.ToString()以將 HTML 塊返回為string

GenerateReceiptTemplate函數中,將所有內容替換為:

Private Shared Function GenerateReceiptTemplate() As String
    Return <html>

            </html>.ToString()
End Function

文件中,復制兩個雙引號"..."之間的 HTML 並將其粘貼到<html></html>塊中。

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

就是這樣。

注意:不確定 VS2010、VS2012 框架是否支持此功能。 分手后要往前看了!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM