{"id":234030,"date":"2022-01-23T08:25:03","date_gmt":"2022-01-23T00:25:03","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=234030"},"modified":"2022-01-08T18:27:07","modified_gmt":"2022-01-08T10:27:07","slug":"vb-logical-conditions","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/vb-logical-conditions.html","title":{"rendered":"ASP.NET Razor – VB \u903b\u8f91\u6761\u4ef6\u7b80\u4ecb"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nRazor \u4e0d\u662f\u4e00\u79cd\u7f16\u7a0b\u8bed\u8a00\u3002\u5b83\u662f\u670d\u52a1\u5668\u7aef\u7684\u6807\u8bb0\u8bed\u8a00\u3002\u7f16\u7a0b\u903b\u8f91\uff1a\u6839\u636e\u6761\u4ef6\u6267\u884c\u4ee3\u7801\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/p>\n

If \u6761\u4ef6<\/strong><\/div>\n

VB \u5141\u8bb8\u6839\u636e\u6761\u4ef6\u6267\u884c\u4ee3\u7801\u3002<\/p>\n

\u4f7f\u7528 if \u8bed\u53e5\u6765\u5224\u65ad\u6761\u4ef6\u3002\u6839\u636e\u5224\u65ad\u7ed3\u679c\uff0cif \u8bed\u53e5\u8fd4\u56de true \u6216\u8005 false\uff1a<\/p>\n

    \n
  1. if \u8bed\u53e5\u5f00\u59cb\u4e00\u4e2a\u4ee3\u7801\u5757<\/li>\n
  2. \u6761\u4ef6\u5199\u5728 if \u548c then \u4e4b\u95f4<\/li>\n
  3. \u5982\u679c\u6761\u4ef6\u4e3a\u771f\uff0cif ... then \u548c end if \u4e4b\u95f4\u7684\u4ee3\u7801\u88ab\u6267\u884c<\/li>\n<\/ol>\n

    \u5b9e\u4f8b<\/strong><\/p>\n

    @Code
    Dim \r\nprice=50
    End Code
    <\/span><html>
    <body>
    @If price>30 \r\nThen \r\n@<p>The price is too high.<\/p>
    End \r\nIf
    <\/span><\/body>
    <\/html><\/pre>\n
    Else \u6761\u4ef6<\/strong><\/div>\n

    if \u8bed\u53e5\u53ef\u4ee5\u5305\u542b else \u6761\u4ef6\u3002<\/p>\n

    else \u6761\u4ef6\u5b9a\u4e49\u4e86\u5f53\u6761\u4ef6\u4e3a\u5047\u65f6\u88ab\u6267\u884c\u7684\u4ee3\u7801\u3002<\/p>\n

    \u5b9e\u4f8b<\/strong><\/p>\n

    \r\n@Code
    Dim \r\nprice=20
    End Code
    <\/span><html>
    <body>
    @if price>30 then \r\n@<p>The price is too high.<\/p>\r\nElse \r\n@<p>The price is OK.<\/p>
    End If
    <\/span><\/body>
    <\/htmlV><\/pre>\n

    \u6ce8\u91ca\uff1a\u5728\u4e0a\u9762\u7684\u5b9e\u4f8b\u4e2d\uff0c\u5982\u679c\u7b2c\u4e00\u4e2a\u6761\u4ef6\u4e3a\u771f\uff0cif \u5757\u7684\u4ee3\u7801\u5c06\u4f1a\u88ab\u6267\u884c\u3002else \u6761\u4ef6\u8986\u76d6\u4e86\u9664 if \u6761\u4ef6\u4e4b\u5916\u7684\"\u5176\u4ed6\u6240\u6709\u60c5\u51b5\"\u3002<\/p>\n

    ElseIf \u6761\u4ef6<\/strong><\/div>\n

    \u591a\u4e2a\u6761\u4ef6\u5224\u65ad\u53ef\u4ee5\u4f7f\u7528 elseif \u6761\u4ef6\uff1a<\/p>\n

    \u5b9e\u4f8b<\/strong><\/p>\n

    @Code
    Dim \r\nprice=25
    End Code
    <\/span><html>
    <body>
    @If price>=30 Then \r\n@<p>The price is high.<\/p>\r\nElseIf price>20 And price<30 \r\n@<p>The price is OK.<\/p>
    Else\r\n@<p>The price is low.<\/p>
    End If \r\n<\/body>
    <\/html><\/span><\/pre>\n

    \u5728\u4e0a\u9762\u7684\u5b9e\u4f8b\u4e2d\uff0c\u5982\u679c\u7b2c\u4e00\u4e2a\u6761\u4ef6\u4e3a\u771f\uff0cif \u5757\u7684\u4ee3\u7801\u5c06\u4f1a\u88ab\u6267\u884c\u3002<\/p>\n

    \u5982\u679c\u7b2c\u4e00\u4e2a\u6761\u4ef6\u4e0d\u4e3a\u771f\u4e14\u7b2c\u4e8c\u4e2a\u6761\u4ef6\u4e3a\u771f\uff0celseif \u5757\u7684\u4ee3\u7801\u5c06\u4f1a\u88ab\u6267\u884c\u3002<\/p>\n

    elseif \u6761\u4ef6\u7684\u6570\u91cf\u4e0d\u53d7\u9650\u5236\u3002<\/p>\n

    \u5982\u679c if \u548c elseif \u6761\u4ef6\u90fd\u4e0d\u4e3a\u771f\uff0c\u6700\u540e\u7684 else \u5757\uff08\u4e0d\u5e26\u6761\u4ef6\uff09\u8986\u76d6\u4e86\"\u5176\u4ed6\u6240\u6709\u60c5\u51b5\"\u3002<\/p>\n

    Select \u6761\u4ef6<\/strong><\/div>\n

    select \u5757\u53ef\u4ee5\u7528\u6765\u6d4b\u8bd5\u4e00\u4e9b\u5355\u72ec\u7684\u6761\u4ef6\uff1a<\/p>\n

    \u5b9e\u4f8b<\/strong><\/p>\n

    @Code
    Dim weekday=DateTime.Now.DayOfWeek
    Dim day=weekday.ToString()
    Dim message=\"\"
    End Code
    <html>
    <body>\r\n@Select Case day
    Case \"Monday\" \r\nmessage=\"This is the first \r\nweekday.\"
    Case \"Thursday\" \r\nmessage=\"Only one day before weekend.\"\r\nCase \"Friday\" \r\nmessage=\"Tomorrow is weekend!\"
    Case Else \r\nmessage=\"Today is \" & day
    End Select
    <p>@message<\/span><\/p>
    <\/body>
    <\/html><\/pre>\n

    \"Select Case\" \u540e\u9762\u7d27\u8ddf\u7740\u6d4b\u8bd5\u503c\uff08day\uff09\u3002\u6bcf\u4e2a\u5355\u72ec\u7684\u6d4b\u8bd5\u6761\u4ef6\u90fd\u6709\u4e00\u4e2a case \u503c\u548c\u4efb\u610f\u6570\u91cf\u7684\u4ee3\u7801\u884c\u3002\u5982\u679c\u6d4b\u8bd5\u503c\u4e0e case \u503c\u76f8\u5339\u914d\uff0c\u76f8\u5e94\u7684\u4ee3\u7801\u884c\u88ab\u6267\u884c\u3002<\/p>\n

    select \u5757\u6709\u4e00\u4e2a\u9ed8\u8ba4\u7684\u60c5\u51b5\uff08Case Else\uff09\uff0c\u5f53\u6240\u6709\u7684\u6307\u5b9a\u7684\u60c5\u51b5\u90fd\u4e0d\u5339\u914d\u65f6\uff0c\u5b83\u8986\u76d6\u4e86\"\u5176\u4ed6\u6240\u6709\u60c5\u51b5\"\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

    VB \u5141\u8bb8\u6839\u636e\u6761\u4ef6\u6267\u884c\u4ee3\u7801\u3002 \u4f7f\u7528 if \u8bed\u53e5\u6765\u5224\u65ad\u6761\u4ef6\u3002\u6839\u636e\u5224\u65ad\u7ed3\u679c\uff0cif \u8bed\u53e5\u8fd4\u56de true \u6216\u8005 fal […]<\/p>\n","protected":false},"author":1470,"featured_media":234020,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-234030","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/234030","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1470"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=234030"}],"version-history":[{"count":5,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/234030\/revisions"}],"predecessor-version":[{"id":234045,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/234030\/revisions\/234045"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/234020"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=234030"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=234030"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=234030"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}