{"id":490,"date":"2021-12-16T18:54:23","date_gmt":"2021-12-16T10:54:23","guid":{"rendered":"http:\/\/www.henrycome.com\/wordpress\/?p=490"},"modified":"2022-03-18T07:20:56","modified_gmt":"2022-03-17T23:20:56","slug":"20211216185413","status":"publish","type":"post","link":"http:\/\/www.henrycome.com\/wordpress\/202112161854\/490","title":{"rendered":"\u3010WPS\u5f00\u53d1\u3011WPS\u7684JS\u548cVBA\u533a\u522b\u4e4b\uff1a\u83b7\u53d6\u6570\u636e\u548c\u8fd4\u56de\u6570\u636e"},"content":{"rendered":"\n<p>\u5148\u5b9e\u73b0\u4e00\u4e2a\u529f\u80fd\uff0c\u5c31\u662f\u5224\u65adA1\u4e2d\u7684\u6570\u5b57\u662f\u5426\u5c0f\u4e8e9\uff0c\u5c0f\u4e8e9\u7684\u8bdd\uff0c\u5c31\u52a01\uff0c\u76f4\u5230\u4e0d\u5c0f\u4e8e9\u505c\u6b62\uff1a<\/p>\n\n\n\n<p>VBA\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Sub testDoWhile()\nSheets(\"sheet1\").Select\nCells.ClearContents\n\nDo While Range(\"a1\").Value &lt; 9\n Range(\"a1\").Value = Range(\"a1\").Value + 1\n Loop\n \nEnd Sub\n<\/code><\/pre>\n\n\n\n<p>JS\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function testDoWhile(){\nSheets.Item(\"Sheet1\").Activate();\nCells.ClearContents();\nRange(\"A1\").Value2=0;\n\nwhile (Range(\"A1\").Value2 &lt; 9){\n    Range(\"A1\").Value2=Range(\"A1\").Value2+1;\n}<\/code><\/pre>\n\n\n\n<p>\u4e24\u8005\u7684\u533a\u522b\uff0c\u6682\u65f6\u51e0\u70b9\uff08\u6682\u65f6\u8fd9\u4e9b\uff09\uff1a<\/p>\n\n\n\n<p>1.\u5199\u6cd5\u7684\u533a\u522b\uff1a<\/p>\n\n\n\n<ol><li>VBA\u6765\u81ea\u4e8eVB\uff0c\u6240\u4ee5\u58f0\u660e\u8fc7\u7a0b\uff08\u6307sub\uff09\u7684\u65f6\u5019\u662fsub\uff0cjs\u7684\u51fd\u6570\u58f0\u660e\u7684\u7279\u70b9\u662ffunction\u548c{}\uff1b<\/li><li>\u58f0\u660e\u65b9\u5f0fjs\u53ef\u4ee5\u76f4\u63a5\u8d4b\u503c\uff0cJS\u6bd4\u8f83\u8981\u7528==\uff0cwhile\u8bed\u53e5\u5199\u6cd5\u533a\u522b\u7b49\uff1b<\/li><li>JS\u8bed\u53e5\u7ed3\u675f\u540e\u9762\u53ef\u4ee5\u52a0\u5206\u53f7\u6216\u6362\u884c\uff08\u8be6\u7ec6<a href=\"https:\/\/www.cnblogs.com\/ricklz\/p\/10342629.html\">\u53c2\u8003<\/a>\uff09\uff0cvba\u8bed\u53e5\u7ed3\u675f\u540e\u9762\u4e0d\u7528\u52a0\u7b26\u53f7\uff0c\u6362\u884c\u8868\u793a\u7ed3\u675f\uff1b<\/li><li>JS\u4ee3\u7801\u592a\u957f\u53ef\u6362\u884c\u4e66\u5199\uff0c\uff08return\u5982\u4f55\u6709\u7ed3\u679c\u8fd4\u56de\uff0c\u4e0d\u53ef\u628a\u7ed3\u679c\u6362\u884c\uff09\uff0cVBA\u4ee3\u7801\u592a\u957f\u5728\u884c\u672b\u5199\u4e0b\u5212\u7ebf_\u8868\u793a\u4ee3\u7801\u6362\u884c\u5199\uff08<a href=\"https:\/\/blog.csdn.net\/csdnhxs\/article\/details\/80438453\">\u53c2\u8003<\/a>\uff09\uff1b<\/li><li>JS\u7528\/\/\u6ce8\u91ca\uff0cvba\u7528&#8217;\u6ce8\u91ca\u7b49\uff1b<\/li><li>\u8f6c\u4e49\u5b57\u7b26\u7684\u533a\u522b\uff0cJS\u4f7f\u7528\\\uff0cvba\u7528\u201c\u201d\u8868\u793a\u201c\uff08VB\u7cfb\u5217\u8bed\u8a00\u6709\u81ea\u5df1\u7684\u89c4\u5219<a href=\"https:\/\/blog.csdn.net\/geniusleft\/article\/details\/198167\">\u53c2\u8003<\/a>\uff0c<a href=\"https:\/\/blog.csdn.net\/tntxia\/article\/details\/83238432\">ACSII\u8868\u548c\u5e38\u6570<\/a>\uff0c<a href=\"https:\/\/cloud.tencent.com\/developer\/article\/1339190\">\u4e0d\u540c\u63a7\u4ef6\u6548\u679c<\/a>\uff09\u3002<\/li><\/ol>\n\n\n\n<p>2.\u5355\u5143\u683c\u53d6\u503c\u7684\u65b9\u5f0f\u533a\u522b\uff1avba\u548cjs\u57fa\u672c\u4e00\u81f4\uff0c\u4f46\u662fvalue\u5c5e\u6027\u4e0a\uff0cvba\u53ef\u4ee5value\u548cvalue2\uff0cjs\u8fd9\u8fb9\u53ea\u80fd\u662fvalue2\uff1bvalue\u548cvalue2\u7684\u533a\u522b<a href=\"http:\/\/www.360doc.com\/content\/18\/0917\/01\/58460801_787256760.shtml\">\u53c2\u8003<\/a>\uff1b<\/p>\n\n\n\n<p>3.\u5de5\u4f5c\u8868\u7684\u6fc0\u6d3b\u65b9\u5f0f\uff1a js\u53ea\u80fd\u4f7f\u7528Activate()\u6765\u6fc0\u6d3b\u5e26\u62ec\u53f7\u6ce8\u610f\u5927\u5c0f\u5199\uff08\u53c2\u8003<a href=\"https:\/\/open.wps.cn\/docs\/office\">WPS\u5b98\u65b9\u6587\u6863<\/a>\uff0c\u4f7f\u7528\u67e5\u627e\u529f\u80fd\u53ea\u627e\u5230\u8fd9\u4e00\u4e2a\u65b9\u6cd5\uff09\uff0cvba\u53ef\u4ee5\u662fselect\u6216\u8005activate\uff08\u5927\u5c0f\u5199\u81ea\u52a8\u66f4\u6b63\u65e0\u9700\u5e26\u62ec\u53f7\uff0c\u8fd9\u4e2a\u62ec\u53f7\u662f\u8bed\u6cd5\u533a\u522b\uff09\uff1b sheets(&#8220;\u5b50\u5bf9\u8c61\u540d\u5b57&#8221;)\uff0cjs\u662fsheets.item(&#8220;\u5b50\u5bf9\u8c61\u540d\u5b57&#8221;)\uff1b<\/p>\n\n\n\n<p>4.\u5bf9\u4e8e\u7a7a\u5355\u5143\u683c\u7684\u5904\u7406\uff1avba\u53ef\u4ee5\u8ba4\u4e3a\u7a7a\u5355\u5143\u662f0\uff08\u5b9e\u9645\u83b7\u53d6\u7684\u662fempty\uff0c\u53ef\u4ee5\u7b49\u4e8e0\uff0c\u89c1\u4e0b\u6587\u5206\u6790\uff09\uff0cjs\u8ba4\u4e3a\u662fundefined,\u6240\u4ee5\uff0cjs\u7f16\u7801\u91cc\u9762\u52a0\u4e00\u53e5 Range(&#8220;A1&#8221;).Value2=0; \u4fdd\u8bc1\u540e\u7eed\u7a0b\u5e8f\u6b63\u786e\u8fd0\u884c\uff1b\u5bf9\u6bd4\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Sub testEmpty()\n\n'\u58f0\u660e\u540e\u8d4b\u503c\u7a7a\nDim a\na = \"\"\nMsgBox (TypeName(a)) 'string\nMsgBox (a = 0) 'false\nMsgBox (a = \"\") 'true\n'MsgBox (a * 1 = 0) '\u7c7b\u578b\u4e0d\u5339\u914d\n\n'\u58f0\u660e\u540e\u8d4b\u503c\u662f\u5b57\u7b26\nDim b\nb = \",\"\nMsgBox (TypeName(b)) 'string\nMsgBox (b = \",\") 'true\n'MsgBox (b * 1 = 0) '\u7c7b\u578b\u4e0d\u5339\u914d\n'\u58f0\u660e\u540e\u4e0d\u8d4b\u503c\nDim c\nMsgBox (TypeName(c)) 'empty\nMsgBox (c = 0) 'true\nMsgBox (c = \"\") 'true\nMsgBox (c * 1 = 0) 'true\n\n'B1\u5355\u5143\u683c\u8f93\u5165=\"\",\u5bf9\u5e94a\u7684\u60c5\u51b5\nMsgBox (TypeName(Range(\"b1\").Value2)) 'string\nMsgBox (Range(\"b1\").Value2 = 0) 'false\nMsgBox (Range(\"b1\").Value2 = \"\") 'true\n'MsgBox (Range(\"b1\").Value2 * 1=0)'\u7c7b\u578b\u4e0d\u5339\u914d\n\n'B2\u5355\u5143\u683c\u8f93\u5165\"\",\u5bf9\u5e94b\u7684\u60c5\u51b5\nMsgBox (TypeName(Range(\"b2\").Value2)) 'string\nMsgBox (Range(\"b2\").Value2 = 0) 'false\nMsgBox (Range(\"b2\").Value2 = \"\") 'false\nMsgBox (Range(\"b2\").Value2 = \"\"\"\"\"\") 'true,1\u4e2a\u5f15\u53f7\u8fd9\u91cc\u75284\u4e2a\uff0c2\u4e2a\u5f15\u53f7\u8fd9\u91cc\u75286\u4e2a\u3002\n'MsgBox (Range(\"b2\").Value2 * 1 = 0) '\u7c7b\u578b\u4e0d\u5339\u914d\u3002\n\n'B3\u5355\u5143\u683c\u4e3a\u7a7a,\u5bf9\u5e94c\u7684\u60c5\u51b5\nMsgBox (TypeName(Range(\"b3\").Value2)) 'empty\nMsgBox (Range(\"b3\").Value2 = 0) 'true\nMsgBox (Range(\"b3\").Value2 = \"\") 'true\nMsgBox (Range(\"b3\").Value2 * 1 = 0) 'true\nEnd Sub\n<\/code><\/pre>\n\n\n\n<p>JS\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function test2()\n\/\/\u6d4b\u8bd5js\u5bf9\u4e8e\u4e0d\u540c\u201c\u7a7a\u201d\u5185\u5bb9\u7684\u5904\u7406\n{\n\/\/\u8bbe\u53d8\u91cfa=\"\"\nvar a=\"\"\nMsgBox (typeof a) \/\/string\nMsgBox (a == 0) \/\/true\nMsgBox (a == \"\") \/\/true\nMsgBox (a * 1==0)\/\/true\n\nvar b=\",\"\nMsgBox (typeof b) \/\/string\nMsgBox (b == 0) \/\/false\nMsgBox (b == \",\") \/\/true\nMsgBox (b * 1==0)\/\/fasle\n\nvar c;\nMsgBox (typeof c) \/\/undefined\nMsgBox (c == 0) \/\/false\nMsgBox (c == \"\") \/\/false\nMsgBox (c * 1==0)\/\/false\n\n\/\/B1\u5355\u5143\u683c\u8f93\u5165=\"\",\u5f53\u505a\u7a7a\u7b49\u540c\u4e8e\u53d8\u91cf=\"\"\nMsgBox (typeof Range(\"b1\").Value2) \/\/string\nMsgBox (Range(\"b1\").Value2 == 0) \/\/true\nMsgBox (Range(\"b1\").Value2 == \"\") \/\/true\nMsgBox (Range(\"b1\").Value2 * 1==0)\/\/true\nMsgBox (Range(\"b1\").Value2 * 1==a)\/\/true\n\n\/\/B2\u5355\u5143\u683c\u8f93\u5165\"\",\u603b\u4f53\u5f53\u505a\u5b57\u7b26\nMsgBox (typeof Range(\"b2\").Value2) \/\/string\nMsgBox (Range(\"b2\").Value2 == 0) \/\/false\nMsgBox (Range(\"b2\").Value2 == \"\") \/\/false\nMsgBox (Range(\"b2\").Value2 == \"\\\"\\\"\") \/\/true,js\u53ef\u4ee5\u4f7f\u7528\u8f6c\u4e49\u7b26\\\u3002\nMsgBox (Range(\"b3\").Value2*1 == 0) \/\/false\n\n\/\/B3\u5355\u5143\u683c\u4e3a\u7a7a,\u603b\u4f53\u7b49\u540c\u4e8eundefined\nMsgBox (typeof Range(\"b3\").Value2) \/\/undefined\nMsgBox (Range(\"b3\").Value2 == 0) \/\/false\nMsgBox (Range(\"b3\").Value2 == \"\") \/\/false\nMsgBox (Range(\"b3\").Value2 * 1 == 0) \/\/false\nMsgBox (Range(\"b3\").Value2 == c)\/\/true\n}<\/code><\/pre>\n\n\n\n<p>\u4ece\u4e0a\u9762\u53ef\u4ee5\u77e5\u9053\uff1avba\u5bf9\u4e8eempty\u53ef\u4ee5\u7b49\u4e8e&#8221;&#8221;\u7a7a\u5b57\u7b26\u548c0\uff0c\u53ef\u4ee5\u6570\u5b66\u8fd0\u7b97\u4e3a0.JS\u5bf9\u4e8e&#8221;&#8221;\u7a7a\u5b57\u7b26\u4e32\u53ef\u4ee5\u7b49\u4e8e0\uff0c\u53ef\u4ee5\u6570\u5b66\u8fd0\u7b97\u3002\u540c\u65f6\uff0c\u5728\u8868\u683c\u5355\u5143\u683c\u5185\u5199\u51fd\u6570\u6d4b\u8bd5\uff0c\u7ed3\u679c\u548cvba\u6d4b\u8bd5\u4e00\u81f4\uff08\u4f7f\u7528WPS\u6d4b\u8bd5\uff09\uff0c\u53c2\u89c1\u4e0b\u9762\u9644\u4ef6\u3002\u53e6\u5916\uff0chtml\u4e2d\uff0c\u83b7\u53d6input\u7a7a\u503c\u662f\u201c\u201d\u7a7a\u5b57\u7b26\u4e32\u3002<\/p>\n\n\n\n<div class=\"wp-block-file\"><a href=\"http:\/\/www.henrycome.com\/wordpress\/wp-content\/uploads\/2021\/12\/JS\u548cvba\u6bd4\u8f831.xlsm\">JS\u548cvba\u6bd4\u8f831<\/a><a href=\"http:\/\/www.henrycome.com\/wordpress\/wp-content\/uploads\/2021\/12\/JS\u548cvba\u6bd4\u8f831.xlsm\" class=\"wp-block-file__button\" download>\u4e0b\u8f7d<\/a><\/div>\n\n\n\n<p>\u4ee5\u4e0a\u6d4b\u8bd5\u73af\u5883\u5982\u4e0b\uff1a<\/p>\n\n\n\n<p>1.Win10 \u4e13\u4e1a\u724819042.662<br>2.WPS 11.1.0.11115-release+VBA6.5+WPS\u5b8f\u7f16\u8f91\u56682.0<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5148\u5b9e\u73b0\u4e00\u4e2a\u529f\u80fd\uff0c\u5c31\u662f\u5224\u65adA1\u4e2d\u7684\u6570\u5b57\u662f\u5426\u5c0f\u4e8e9\uff0c\u5c0f\u4e8e9\u7684\u8bdd\uff0c\u5c31\u52a01\uff0c\u76f4\u5230\u4e0d\u5c0f\u4e8e9\u505c\u6b62\uff1a VBA\u4ee3\u7801\uff1a JS\u4ee3\u7801 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[58,23],"tags":[],"_links":{"self":[{"href":"http:\/\/www.henrycome.com\/wordpress\/wp-json\/wp\/v2\/posts\/490"}],"collection":[{"href":"http:\/\/www.henrycome.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.henrycome.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.henrycome.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.henrycome.com\/wordpress\/wp-json\/wp\/v2\/comments?post=490"}],"version-history":[{"count":13,"href":"http:\/\/www.henrycome.com\/wordpress\/wp-json\/wp\/v2\/posts\/490\/revisions"}],"predecessor-version":[{"id":752,"href":"http:\/\/www.henrycome.com\/wordpress\/wp-json\/wp\/v2\/posts\/490\/revisions\/752"}],"wp:attachment":[{"href":"http:\/\/www.henrycome.com\/wordpress\/wp-json\/wp\/v2\/media?parent=490"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.henrycome.com\/wordpress\/wp-json\/wp\/v2\/categories?post=490"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.henrycome.com\/wordpress\/wp-json\/wp\/v2\/tags?post=490"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}