{"id":244,"date":"2023-07-29T16:48:35","date_gmt":"2023-07-29T07:48:35","guid":{"rendered":"https:\/\/rafa-system.com\/vba\/?p=244"},"modified":"2023-07-29T16:48:35","modified_gmt":"2023-07-29T07:48:35","slug":"post-244","status":"publish","type":"post","link":"https:\/\/rafa-system.com\/vba\/2023\/07\/29\/post-244\/","title":{"rendered":"\u30a8\u30e9\u30fc\u51e6\u7406"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u30a8\u30e9\u30fc\u304c\u51fa\u305f\u3089\u30e9\u30d9\u30eb\u306b\u98db\u3076\uff1aOn Error Goto \u30e9\u30d9\u30eb\u540d<\/h2>\n\n\n\n<pre class=\"wp-block-luxe-blocks-syntaxhighlighter line-numbers language-vba\"><code class=\"language-vba\">Sub test1()\n    On Error GoTo ErrHandler\n\n    Dim x As Long, y As Long\n    x = 1\n    Debug.Print x \/ y\n    \n    Exit Sub\n\nErrHandler:\n    Debug.Print \"\u30a8\u30e9\u30fc\uff1a\" &amp; Err.Description\nEnd Sub<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u30a8\u30e9\u30fc\u304c\u51fa\u306a\u304b\u3063\u305f\u3089\u51e6\u7406\u3092\u7d42\u4e86\uff1aExit Sub<\/h2>\n\n\n\n<p>\u3053\u308c\u304c\u7121\u3044\u3068\u300cEnd Sub\u300d\u307e\u3067\u51e6\u7406\u304c\u9032\u884c\u3057\u3066\u3044\u304f\u306e\u3067\u3001\u30e9\u30d9\u30eb\u884c\u306b\u66f8\u3044\u305f\u51e6\u7406\u3082\u5b9f\u884c\u3055\u308c\u3066\u3057\u307e\u3046<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u30a8\u30e9\u30fc\u3092\u7121\u8996\u3059\u308b\uff1aOn Error Resume Next<\/h2>\n\n\n\n<pre class=\"wp-block-luxe-blocks-syntaxhighlighter line-numbers language-vba\"><code class=\"language-vba\">Sub test2()\n    On Error Resume Next\n\n    Dim x As Long, y As Long\n    x = 1\n    Debug.Print x \/ y\n    Debug.Print \"\u30a8\u30e9\u30fc\u306f\u7121\u8996\u3055\u308c\u305f\"\n    \n    Dim a As Long, b As Long\n    x = 5\n    Debug.Print a \/ b\n    Debug.Print \"2\u56de\u76ee\u30a8\u30e9\u30fc\u3082\u7121\u8996\"\nEnd Sub<\/code><\/pre>\n\n\n\n<p>\u3061\u306a\u307f\u306b\u300cResume\u300d\u306f\u300c\u308a\u305a\u30fc\u3080\u300d\u3068\u8aad\u3080\u3000\u300c\u518d\u958b\u3059\u308b\u300d\u7684\u306a\u610f\u5473\uff08<a rel=\"noreferrer noopener\" href=\"https:\/\/ejje.weblio.jp\/content\/resume\" target=\"_blank\">Weblio\u3088\u308a<\/a>\uff09<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"825\" height=\"230\" src=\"https:\/\/rafa-system.com\/vba\/wp-content\/uploads\/2023\/07\/image-38.png\" alt=\"\" class=\"wp-image-245\" srcset=\"https:\/\/rafa-system.com\/vba\/wp-content\/uploads\/2023\/07\/image-38.png 825w, https:\/\/rafa-system.com\/vba\/wp-content\/uploads\/2023\/07\/image-38-300x84.png 300w, https:\/\/rafa-system.com\/vba\/wp-content\/uploads\/2023\/07\/image-38-768x214.png 768w\" sizes=\"auto, (max-width: 825px) 100vw, 825px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u30a8\u30e9\u30fc\u51e6\u7406\u3092\u89e3\u9664\u3059\u308b\uff1aOn Error GoTo 0<\/h2>\n\n\n\n<p>\u3053\u308c\u4ee5\u964d\u306b\u30a8\u30e9\u30fc\u304c\u51fa\u305f\u3089\u3001\u7121\u8996\u3057\u305f\u308a\u30e9\u30d9\u30eb\u306b\u98db\u3093\u3060\u308a\u3057\u306a\u3044<\/p>\n\n\n\n<pre class=\"wp-block-luxe-blocks-syntaxhighlighter line-numbers language-vba\"><code class=\"language-vba\">Sub test2()\n    On Error Resume Next\n\n        Dim x As Long, y As Long\n        x = 1\n        Debug.Print x \/ y\n        Debug.Print \"\u30a8\u30e9\u30fc\u306f\u7121\u8996\u3055\u308c\u305f\"\n    \n    On Error GoTo 0\n    \n    Dim a As Long, b As Long\n    a = 5\n    Debug.Print a \/ b    '\u30a8\u30e9\u30fc\u304c\u51fa\u308b\n\nEnd Sub<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u30e9\u30d9\u30eb\u304b\u3089\u5143\u306e\u4f4d\u7f6e\u306b\u623b\u308b\uff1aResume<\/h2>\n\n\n\n<p><span style=\"color: #dc143c\" class=\"text-color\">\u300cExit Sub\u300d\u3092\u5fd8\u308c\u308b\u3068\u7121\u9650\u30eb\u30fc\u30d7\u306b\u9665\u308b\u306e\u3067\u6ce8\u610f<\/span><\/p>\n\n\n\n<pre class=\"wp-block-luxe-blocks-syntaxhighlighter line-numbers language-vba\"><code class=\"language-vba\">Sub test1()\n\n    On Error GoTo ErrHandler\n\n    Dim x As Long, y As Long\n    x = 1    \n    Debug.Print x \/ y\n    \n    Exit Sub\n\nErrHandler:\n    y = 5\n    Debug.Print \"y\u306f\u3084\u3063\u3071 \" &amp; y\n    Resume\n\nEnd Sub<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u30a8\u30e9\u30fc\u304c\u51fa\u305f\u308910\u56de\u307e\u3067\u518d\u8a66\u884c\u3059\u308b<\/h2>\n\n\n\n<p>ChatGPT\u4f5c\u306e\u518d\u8a66\u884c\u30ed\u30b8\u30c3\u30af\u3000Sleep\u95a2\u6570\u3068\u7d44\u307f\u5408\u308f\u305b\u308b\u3068\u300c1\u79d2\u304a\u304d\u306b\u518d\u8a66\u884c\u300d\u3068\u3044\u3046\u306e\u3082\u53ef\u80fd<\/p>\n\n\n\n<pre class=\"wp-block-luxe-blocks-syntaxhighlighter line-numbers language-vba\"><code class=\"language-vba\">Sub RetryOnErrors()\n    Dim maxRetries As Integer\n    Dim retryCount As Integer\n    Dim success As Boolean\n    \n    maxRetries = 10 ' \u6700\u5927\u518d\u8a66\u884c\u56de\u6570\u309210\u56de\u306b\u8a2d\u5b9a\n    retryCount = 0\n    success = False\n    \n    Do While retryCount &lt; maxRetries And Not success\n        On Error Resume Next ' \u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u3066\u3082\u5373\u5ea7\u306b\u6b21\u306e\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\n        \n        ' \u3053\u3053\u306b\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3059\u308b\u53ef\u80fd\u6027\u306e\u3042\u308b\u30b3\u30fc\u30c9\u3092\u8a18\u8ff0\u3057\u307e\u3059\n        ' \u4f8b\uff1a\u30c7\u30fc\u30bf\u306e\u53d6\u5f97\u3084\u51e6\u7406\u3092\u884c\u3046\u95a2\u6570\u306a\u3069\n        \n        If Err.Number &lt;> 0 Then\n            ' \u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u5834\u5408\u306e\u51e6\u7406\n            retryCount = retryCount + 1\n            Err.Clear ' \u30a8\u30e9\u30fc\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u30af\u30ea\u30a2\u3057\u3066\u6b21\u306e\u8a66\u884c\u306b\u5099\u3048\u308b\n        Else\n            ' \u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u306a\u304b\u3063\u305f\u5834\u5408\u306e\u51e6\u7406\n            success = True ' \u6210\u529f\u30d5\u30e9\u30b0\u3092\u7acb\u3066\u308b\n        End If\n        \n        On Error GoTo 0 ' \u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u3092\u5143\u306b\u623b\u3059\n    Loop\n    \n    If success Then\n        MsgBox \"\u51e6\u7406\u304c\u6210\u529f\u3057\u307e\u3057\u305f\u3002\", vbInformation\n    Else\n        MsgBox \"\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002\u518d\u8a66\u884c\u56de\u6570\u304c\u4e0a\u9650\u306b\u9054\u3057\u307e\u3057\u305f\u3002\", vbExclamation\n    End If\nEnd Sub<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u30a8\u30e9\u30fc\u304c\u51fa\u305f\u3089\u30e9\u30d9\u30eb\u306b\u98db\u3076\uff1aOn Error Goto \u30e9\u30d9\u30eb\u540d \u30a8\u30e9\u30fc\u304c\u51fa\u306a\u304b\u3063\u305f\u3089\u51e6\u7406\u3092\u7d42\u4e86\uff1aExit Sub \u3053\u308c\u304c\u7121\u3044\u3068\u300cEnd Sub\u300d\u307e\u3067\u51e6\u7406\u304c\u9032\u884c\u3057\u3066\u3044\u304f\u306e\u3067\u3001\u30e9\u30d9\u30eb\u884c\u306b\u66f8\u3044\u305f\u51e6\u7406\u3082\u5b9f\u884c\u3055\u308c\u3066\u3057\u307e\u3046 \u30a8\u30e9\u30fc [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[22],"class_list":["post-244","post","type-post","status-publish","format-standard","hentry","category-15","tag-22"],"_links":{"self":[{"href":"https:\/\/rafa-system.com\/vba\/wp-json\/wp\/v2\/posts\/244","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rafa-system.com\/vba\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rafa-system.com\/vba\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rafa-system.com\/vba\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rafa-system.com\/vba\/wp-json\/wp\/v2\/comments?post=244"}],"version-history":[{"count":1,"href":"https:\/\/rafa-system.com\/vba\/wp-json\/wp\/v2\/posts\/244\/revisions"}],"predecessor-version":[{"id":246,"href":"https:\/\/rafa-system.com\/vba\/wp-json\/wp\/v2\/posts\/244\/revisions\/246"}],"wp:attachment":[{"href":"https:\/\/rafa-system.com\/vba\/wp-json\/wp\/v2\/media?parent=244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rafa-system.com\/vba\/wp-json\/wp\/v2\/categories?post=244"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rafa-system.com\/vba\/wp-json\/wp\/v2\/tags?post=244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}