{"id":826,"date":"2024-06-21T08:57:28","date_gmt":"2024-06-21T00:57:28","guid":{"rendered":"http:\/\/www.wyrcad.com\/?p=826"},"modified":"2024-06-24T17:36:10","modified_gmt":"2024-06-24T09:36:10","slug":"autocad-%e4%b8%ba%e5%9b%be%e5%85%83%e6%b7%bb%e5%8a%a0%e6%89%a9%e5%b1%95%e6%95%b0%e6%8d%ae-xdata","status":"publish","type":"post","link":"https:\/\/www.wyrcad.com\/?p=826","title":{"rendered":"\u6570\u503c\u51fd\u6570\u7cfb\u5217\u4e4b\u4e00"},"content":{"rendered":"\n<p>&#8216;\u5c06\u4efb\u610f\u6574\u6570\u5206\u89e3\u4e3a\u7b49\u6bd4\u6570\u5217\u4e4b\u4e2d\u7684\u6570\u503c<br>Dim vRet As Variant<br>vRet = GeometricSeriesEx(2147483647)<br>For I = LBound(vRet) To UBound(vRet)<br>Debug.Print vRet(I)<br>Next I<\/p>\n\n\n\n<p>Public Function GeometricSeriesEx(ByVal lData As Long) As Variant &#8216;\u5206\u89e3\u6574\u6570\u4e3a 1 2 4 8 16 32 64 \u2026 \u2026\uff0c\u4e14\u6bcf\u4e2a\u6570\u53ea\u51fa\u73b0\u4e00\u6b21<br>Dim I As Integer, J As Integer<br>If Not IsNumericEx(lData) Then Exit Function<br>Dim sBin As String<br>sBin = DEC_to_BIN(lData)<br>Dim iCount As Integer<br>Dim TempArray() As Long<br>For I = 1 To Len(sBin)<br>If Mid(sBin, I, 1) = &#8220;1&#8221; Then<br>ReDim Preserve TempArray(0 To iCount)<br>TempArray(iCount) = 2 ^ (Len(sBin) &#8211; I)<br>iCount = iCount + 1<br>End If<br>Next I<br>GeometricSeriesEx = TempArray<br>End Function<\/p>\n\n\n\n<p>Public Function DEC_to_BIN(Dec As Long) As String &#8216;\u5341\u8fdb\u5236\u8f6c\u5316\u4e3a\u4e8c\u8fdb\u5236<br>DEC_to_BIN = &#8220;&#8221;<br>Do While Dec &gt; 0<br>DEC_to_BIN = Dec Mod 2 &amp; DEC_to_BIN<br>Dec = Dec \\ 2<br>Loop<br>End Function<\/p>\n\n\n\n<p>Public Function IsNumericEx(ByVal sData As String) As Boolean &#8216;\u7535\u5b50\u8868\u683c\u7a7a\u683c\u88ab IsNumeric \u89c6\u4e3a\u6570\u503c 0,IsNumericEx \u5219\u89c6\u4e3a\u5b57\u7b26 &#8220;&#8221;<br>IsNumericEx = False<br>sData = Trim(sData)<br>If sData = &#8220;&#8221; Then Exit Function<br>IsNumericEx = IsNumeric(sData)<br>End Function<\/p>\n\n\n\n<p>Public Function IsInteger(ByVal txtString As String) As Boolean &#8216;\u662f\u6570\u503c\uff0c\u4e14\u662f\u6574\u6570<br>IsInteger = True<br>If Not IsNumeric(txtString) Then<br>IsInteger = False<br>Exit Function<br>End If<br>If Not CDbl(txtString) \/ 1 = CDbl(txtString) \\ 1 Then<br>IsInteger = False<br>End If<br>End Function<\/p>\n\n\n\n<p>Public Function IsInRange(ByVal sData As String, ByVal LowerLimit As Double, ByVal UpperLimit As Double, ByVal bAllowThreshold As Boolean) As Boolean &#8216;\u5224\u65ad\u67d0\u6570\u636e\u662f\u4e0d\u662f\u6570\u503c\uff0c\u4e14\u662f\u5426\u5728\u754c\u5185<br>IsInRange = False<br>If Not IsNumeric(sData) Then Exit Function &#8216;\u5b57\u7b26\u7b49\u89c6\u4e3a\u8d8a\u754c,\u9632\u6b62\u4ee5\u4e0b\u6bd4\u8f83\u65f6\u53d1\u751f\u9519\u8bef<br>If bAllowThreshold Then &#8216;\u538b\u754c\u7b97\u5728\u754c\u5185<br>If CDbl(sData) &gt; UpperLimit Then Exit Function &#8216;\u8d8a\u4e0a\u754c<br>If CDbl(sData) &lt; LowerLimit Then Exit Function &#8216;\u8d8a\u4e0b\u754c Else &#8216;\u538b\u754c\u4e0d\u7b97\u5728\u754c\u5185 If CDbl(sData) &gt;= UpperLimit Then Exit Function &#8216;\u8d8a\u4e0a\u754c<br>If CDbl(sData) &lt;= LowerLimit Then Exit Function &#8216;\u8d8a\u4e0b\u754c<br>End If<br>IsInRange = True<br>End Function<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8216;\u5c06\u4efb\u610f\u6574\u6570\u5206\u89e3\u4e3a\u7b49\u6bd4\u6570\u5217\u4e4b\u4e2d\u7684\u6570\u503cDim vRet As VariantvRet = Geome &hellip; <a href=\"https:\/\/www.wyrcad.com\/?p=826\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201c\u6570\u503c\u51fd\u6570\u7cfb\u5217\u4e4b\u4e00\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[24,17],"class_list":["post-826","post","type-post","status-publish","format-standard","hentry","category-bianchengyuandi","tag-vb","tag-biancheng"],"_links":{"self":[{"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts\/826","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=826"}],"version-history":[{"count":14,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts\/826\/revisions"}],"predecessor-version":[{"id":878,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts\/826\/revisions\/878"}],"wp:attachment":[{"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=826"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=826"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=826"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}