{"id":3577,"date":"2020-03-28T21:18:02","date_gmt":"2020-03-28T12:18:02","guid":{"rendered":"http:\/\/kats-eye.net\/info\/?p=3577"},"modified":"2020-03-28T21:53:19","modified_gmt":"2020-03-28T12:53:19","slug":"excel-vba","status":"publish","type":"post","link":"https:\/\/kats-eye.net\/info\/2020\/03\/28\/excel-vba\/","title":{"rendered":"\u30a8\u30af\u30bb\u30eb\u3067\u30b9\u30c6\u30c3\u30d4\u30f3\u30b0\u30e2\u30fc\u30bf\u30fc\u4f4d\u7f6e\u6c7a\u3081"},"content":{"rendered":"\n<h2 class=\"has-text-color\" style=\"color:#000596\"><strong>\u30a8\u30af\u30bb\u30eb\u3067\u30b9\u30c6\u30c3\u30d4\u30f3\u30b0\u30e2\u30fc\u30bf\u30fc\u4f4d\u7f6e\u6c7a\u3081<\/strong><\/h2>\n\n\n\n<p>\u3000ARDUINO   CNC-SHILD\u306e\u4f7f\u3044\u65b9\u3068\u30d1\u30bd\u30b3\u30f3\u304b\u3089ARDUINO\u306b\u30b7\u30ea\u30a2\u30eb\u901a\u4fe1\u3067G\u30b3\u30fc\u30c9\u3092\u9001\u4fe1\u3059\u308bGRBL\u306e\u4f7f\u3044\u65b9\u306b\u3064\u3044\u3066\u6295\u7a3f\u3057\u307e\u3057\u305f\u3002\u307e\u305f\u3001\u30d1\u30bd\u30b3\u30f3\u304b\u3089\u30a8\u30af\u30bb\u30ebVBA\u3092\u4f7f\u3063\u3066\u3001ARDUINO\u306b\u30b7\u30ea\u30a2\u30eb\u901a\u4fe1\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u3082\u6295\u7a3f\u3057\u307e\u3057\u305f\u3002<br>\u3000\u3053\u308c\u3089\u6295\u7a3f\u306e\u5185\u5bb9\u3092\u30d9\u30fc\u30b9\u306b\u3001\u30a8\u30af\u30bb\u30eb\u304b\u3089ARDUINO\u306bG\u30b3\u30fc\u30c9\u9001\u4fe1\u3057\u3001\u30b9\u30c6\u30c3\u30d4\u30f3\u30b0\u30e2\u30fc\u30bf\u30fc\u306e\u4f4d\u7f6e\u6c7a\u3081\u3092\u884c\u3063\u3066\u307f\u307e\u3059\u3002<br>\u3000\u5b9f\u969b\u306b\u30b9\u30e9\u30a4\u30c9\u30c6\u30fc\u30d6\u30eb\u304c\u3042\u308b\u3068\u826f\u3044\u306e\u3067\u3059\u304c\u3001\u6e96\u5099\u304c\u5927\u5909\u306a\u306e\u3067\u3001\u30e2\u30fc\u30bf\u30fc\u306e\u89d2\u5ea6\u3067\u7c21\u6613\u7684\u306b\u5224\u65ad\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<br><\/p>\n\n\n\n<h2 class=\"has-text-color\" style=\"color:#000596\">\u30a8\u30af\u30bb\u30eb\u306e\u6e96\u5099\uff08\u95a2\u9023\u6295\u7a3f\u8a18\u4e8b\uff09<\/h2>\n\n\n\n<p>\u3000\u65e2\u306b\u6295\u7a3f\u3057\u305f\u4e0b\u8868\u306e\u8a18\u4e8b\u306e\u901a\u308a\u3001\u914d\u7dda\u30fb\u8a2d\u5b9a\u3068\u30a8\u30af\u30bb\u30ebVBA\u3067\u30b7\u30ea\u30a2\u30eb\u901a\u4fe1\u3067\u304d\u308b\u3088\u3046\u306bAPI\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3010\u95a2\u9023\u6295\u7a3f\u8a18\u4e8b\u3011<\/p>\n\n\n\n<table style=\"height: 92px; width: 100%; border-collapse: collapse; border-color: #000000;\" border=\"1\">\n<tbody>\n<tr style=\"height: 23px;\">\n<td style=\"width: 12.8692%; height: 23px; background-color: #807d7d; border-color: #000000; text-align: center;\"><span style=\"font-size: 12pt;\">\u756a\u53f7<\/span><\/td>\n<td style=\"width: 87.1308%; height: 23px; background-color: #807d7d; border-color: #000000; text-align: center;\">\u95a2\u9023\u6295\u7a3f<\/td>\n<\/tr>\n<tr style=\"height: 23px;\">\n<td style=\"width: 12.8692%; height: 23px; border-color: #000000; text-align: center;\"><span style=\"font-size: 12pt;\">\uff11<\/span><\/td>\n<td style=\"width: 87.1308%; height: 23px; border-color: #000000;\"><span style=\"font-size: 12pt;\">&nbsp; <a href=\"https:\/\/kats-eye.net\/info\/2020\/03\/14\/arduino-cnc_shield\/\" target=\"_blank\" rel=\"noopener noreferrer\">ARDUINO\u3067CNC\u30b7\u30fc\u30eb\u30c9\u3092\u4f7f\u3046<\/a><\/span><\/td>\n<\/tr>\n<tr style=\"height: 23px;\">\n<td style=\"width: 12.8692%; height: 23px; border-color: #000000; text-align: center;\"><span style=\"font-size: 12pt;\">\uff12<\/span><\/td>\n<td style=\"width: 87.1308%; height: 23px; border-color: #000000;\"><span style=\"font-size: 12pt;\">&nbsp; <a href=\"https:\/\/kats-eye.net\/info\/2020\/03\/17\/grbl-01\/\" target=\"_blank\" rel=\"noopener noreferrer\">ARDUINO\u3067\u306eGRBL\u306e\u4f7f\u3044\u65b9<\/a><\/span><\/td>\n<\/tr>\n<tr style=\"height: 23px;\">\n<td style=\"width: 12.8692%; height: 23px; border-color: #000000; text-align: center;\"><span style=\"font-size: 12pt;\">\uff13<\/span><\/td>\n<td style=\"width: 87.1308%; height: 23px; border-color: #000000;\"><span style=\"font-size: 12pt;\">&nbsp; <a href=\"https:\/\/kats-eye.net\/info\/2020\/03\/23\/excel-arduino\/\" target=\"_blank\" rel=\"noopener noreferrer\">\u30a8\u30af\u30bb\u30ebVBA\u3067ARDUINO\u306b\u30b7\u30ea\u30a2\u30eb\u901a\u4fe1\u3059\u308b<\/a><\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"has-text-color\" style=\"color:#000596\">\u30a8\u30af\u30bb\u30eb\u30d7\u30ed\u30b0\u30e9\u30e0\u6982\u8981<\/h2>\n\n\n\n<p>\u3000\u6b21\u306e\u56f3\u306f\u4eca\u56de\u4f5c\u6210\u3057\u305f\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u30a8\u30af\u30bb\u30eb\u30b7\u30fc\u30c8\u3067\u3059\u3002<br>\u3000\u30b7\u30fc\u30c8\u4e0a\u306b\u30b3\u30de\u30f3\u30c9\u30dc\u30bf\u30f3\u3092\uff13\u3064\u914d\u7f6e\u3057\u3001\u2460\u539f\u70b9\u5fa9\u5e30\uff0c\u2461\u5897\u91cf\u79fb\u52d5\uff0c\u2462\u9023\u7d9a\u904b\u8ee2\uff08\u7d76\u5bfe\u4f4d\u7f6e\u6307\u5b9a\uff09\u306e\uff13\u3064\u306e\u52d5\u4f5c\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<br>\u3000\u57fa\u672c\u7684\u306b\u306f\u904e\u53bb\u306e\u6295\u7a3f\u8a18\u4e8b\u306b\u66f8\u3044\u305f\u5185\u5bb9\u3092\u30a8\u30af\u30bb\u30ebVBA\u3067\u9023\u7d9a\u7684\u306b\u4f4d\u7f6e\u6c7a\u3081\u51fa\u6765\u308b\u69d8\u306b\u3057\u305f\u3082\u306e\u3067\u3059\u3002<br>\u3000<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"709\" height=\"779\" src=\"https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2020\/03\/101.png\" alt=\"\" class=\"wp-image-3590\" srcset=\"https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2020\/03\/101.png 709w, https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2020\/03\/101-273x300.png 273w\" sizes=\"(max-width: 709px) 100vw, 709px\" \/><\/figure>\n\n\n\n<p>\u3000\u56f3\u306e\u901a\u308a\u3001\u5897\u91cf\u6307\u5b9a\u79fb\u52d5\u3067\u306f\u3001X\u8ef8(\uff13\u5217)\uff0cY\u8ef8(\uff14\u5217)\u306b\u73fe\u5728\u4f4d\u7f6e\u306b\u5bfe\u3059\u308b\u5897\u52a0\u91cf(\u5358\u4f4d\uff1amm)\u3092\u6307\u5b9a\u3057\u79fb\u52d5\u3057\u307e\u3059\u3002\u201c\u5897\u91cf\u79fb\u52d5\u201d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u3001G\u30b3\u30fc\u30c9(G91X**Y**)\u3092\u751f\u6210\u3057ARDUINO\u5074\u306b\u30b7\u30ea\u30a2\u30eb\u9001\u4fe1\u3057\u307e\u3059\u3002\u5f15\u304d\u7d9a\u304d\u3001\u201d ? \u201d \u30b3\u30de\u30f3\u30c9\u3067ARDUINO\u5074\u30b9\u30c6\u30fc\u30bf\u30b9\u3092\u78ba\u8a8d\u3057\u3001\u201cIdle\u201d \uff08\u505c\u6b62\uff09\u72b6\u614b\u30c7\u30fc\u30bf\u53d7\u4fe1\u5f8c\u3001G\u30b3\u30fc\u30c9(G92X0<strong>Y0<\/strong>)\u3092\u9001\u4fe1\u3057\u52d5\u4f5c\u539f\u70b9\u3092\u521d\u671f\u5316\u3057\u307e\u3059\u3002<br><br>\u3000\u540c\u69d8\u306b\u9023\u7d9a\u904b\u8ee2\u3067\u306f\u3001X\u8ef8(\uff13\u5217)\uff0cY\u8ef8(\uff14\u5217)\u306b \u6307\u5b9a\u3057\u305f\u7d76\u5bfe\u4f4d\u7f6e\u306b\u5bfe\u5fdc\u3059\u308b  G\u30b3\u30fc\u30c9(G90X**Y**)\u3092\u751f\u6210\u3057\u3001ARDUINO\u5074\u306b\u9001\u4fe1\u3057\u307e\u3059\u3002\u9023\u7d9a\u904b\u8ee2\u3067\u306f\u6700\u5927\uff11\uff10\u30f6\u6240\u306e\u4f4d\u7f6e\u3092\u767b\u9332\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u3001\uff11\uff5e10\u306e\u9806\u756a(\uff12\u5217)\u306b\u4f4d\u7f6e\u6c7a\u3081\u3092\u884c\u3044\u307e\u3059\u3002\u4f4d\u7f6e\u6307\u5b9a\u304c\u7121\u3044\u5834\u5408\u306f\u51e6\u7406\u3092\u4e2d\u65ad\u3057\u307e\u3059\u3002<br>\u3000\u30b7\u30fc\u30c8\uff14\u5217\u306b\u306f\u9001\u4fe1\u3057\u305fG\u30b3\u30fc\u30c9\uff0c\uff15\u5217\u306b\u306f\u53d7\u4fe1\u3057\u305f \u201cIdle\u201d \uff08\u505c\u6b62\uff09\u72b6\u614b\u30c7\u30fc\u30bf \u3092\u8868\u793a\u3057\u307e\u3059\u3002\u4eca\u56de\u3001\u5b9f\u969b\u306b\u306f\u30b9\u30e9\u30a4\u30c9\u30c6\u30fc\u30d6\u30eb\u304c\u3042\u308a\u307e\u305b\u3093\u306e\u3067\u3001\u30b9\u30c6\u30c3\u30d4\u30f3\u30b0\u30e2\u30fc\u30bf\u30fc\u306e\u56de\u8ee2\u89d2\u5ea6\u3067\u9069\u5207\u306b\u51e6\u7406\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3059\u308b\u70ba\u306b\u3001\u6307\u5b9a\u79fb\u52d5\u91cf\u3092\uff14\uff10(mm\/\u56de\u8ee2)\u3068\u3057\u3066\u56de\u8ee2\u89d2\u5ea6\u306b\u5909\u63db\u8868\u793a\u3057\u3066\u3044\u307e\u3059\u3002<br><\/p>\n\n\n\n<h2 class=\"has-text-color\" style=\"color:#000596\">\u30b9\u30c6\u30c3\u30d4\u30f3\u30b0\u30e2\u30fc\u30bf\u30fc\u4f4d\u7f6e\u6c7a\u3081\u52d5\u753b<\/h2>\n\n\n\n<p>\u3000\u52d5\u753b\u5185\u306e\u77e2\u5370\uff08\u2191\uff09\u304c\u4e0a\u5411\u304d\u72b6\u614b\u3092\uff10\u5ea6\u3068\u3057\u3066\u3001\u53f3\u56de\u308a\u306b\u56de\u8ee2\u3059\u308b\u3068\u89d2\u5ea6\u304c\u5897\u52a0\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/1vU2jD8lYIw\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen=\"\"><\/iframe>\n\n\n\n<p>\u3000\u52d5\u753b\u306f\u6b21\u30a8\u30af\u30bb\u30eb\u30b7\u30fc\u30c8\u306e\u901a\u308a\u3001\u4f4d\u7f6e\u6c7a\u3081\u3092\u3057\u3066\u3044\u307e\u3059\u3002\u3000<br>\u3000\u6307\u5b9a\u4f4d\u7f6e\u306b\u5bfe\u3057\u3066\u3001\u56de\u8ee2\u65b9\u5411\u30fb\u91cf\u306f\u6c7a\u307e\u308b\u306e\u3067\u3001\u5fc5\u305a\u3057\u3082\u52d5\u753b\u5185\u306e\u8868\u793a\u89d2\u5ea6\u306b\u5bfe\u3057\u3066\u6700\u77ed\u65b9\u5411\u30fb\u91cf\u306b\u306f\u306a\u308a\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"896\" height=\"549\" src=\"https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2020\/03\/103.png\" alt=\"\" class=\"wp-image-3596\" srcset=\"https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2020\/03\/103.png 896w, https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2020\/03\/103-300x184.png 300w, https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2020\/03\/103-768x471.png 768w\" sizes=\"(max-width: 896px) 100vw, 896px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"has-text-color\" style=\"color:#000596\">\u30d7\u30ed\u30b0\u30e9\u30e0<\/h2>\n\n\n\n<p>\u3000\u30a8\u30af\u30bb\u30ebVBA\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u63b2\u8f09\u3057\u307e\u3059\u3002<\/p>\n\n\n<pre class=\"height-set:true lang:default decode:true   \" title=\"VBA_SERIAL_TO_ARDUINO\">Option Explicit\n\nPrivate Declare Sub Sleep Lib \"kernel32\" (ByVal ms As Long)\n\n\n\n'\u539f\u70b9\u5fa9\u5e30\nPrivate Sub CommandButton3_Click()\n    Dim res\n    Dim msg\n    Dim G_CD As String\n    Dim sht\n    \n    sht = ActiveSheet.Name\n    \n    Worksheets(sht).Range(\"E1:F1\").ClearContents\n    \n    G_CD = \"$H\"\n    Worksheets(sht).Cells(1, 5).Value = G_CD\n    \n    res = StartSerialComm(G_CD, \"COM4\")\n\n  \n    Do\n        Sleep (500)\n        DoEvents\n        \n        res = StartSerialComm(\"?\", \"COM4\")\n  \n        If InStr(res, \"Idle\") Then\n            Exit Do\n        End If\n        \n    Loop\n  \n    res = Replace(Replace(Replace(res, \"ok\", \"\"), \")\", \"\"), \"(\", \"\")\n    \n    Worksheets(sht).Cells(1, 6).Value = res\n  \n    msg = MsgBox(\"\u539f\u70b9\u5fa9\u5e30\u3092\u7d42\u4e86\u3057\u307e\u3057\u305f\u3002\" + vbCrLf + vbCrLf + \"\uff08\" + res + \"\uff09\", vbOKOnly)\n    \nEnd Sub\n\n'\u5897\u91cf\u79fb\u52d5\nPrivate Sub CommandButton1_Click()\n\n      \n    Dim sht\n    Dim res\n    Dim pos_X, pos_Y\n    Dim G_CD As String\n\n    \n    \n    sht = ActiveSheet.Name\n    \n    Worksheets(sht).Range(\"E5:F5\").ClearContents\n    \n\n    pos_X = Trim(Worksheets(sht).Cells(5, 3).Value)\n    pos_Y = Trim(Worksheets(sht).Cells(5, 4).Value)\n        \n    If pos_X = \"\" &amp; pos_Y = \"\" Then Exit Sub\n        \n    If pos_X = \"\" Then pos_X = \"0\"\n    If pos_Y = \"\" Then pos_Y = \"0\"\n        \n        \n    G_CD = \"G91G0X\" &amp; pos_X &amp; \"Y\" &amp; pos_Y\n    Worksheets(sht).Cells(5, 5).Value = G_CD\n            \n    res = StartSerialComm(G_CD, \"COM4\")\n\n    Do\n        Sleep (500)\n        DoEvents\n        \n        res = StartSerialComm(\"?\", \"COM4\")\n  \n        If InStr(res, \"Idle\") Then\n            Exit Do\n        End If\n    Loop\n  \n    res = StartSerialComm(\"G90G92X0Y0\", \"COM4\")\n    \n    Do\n        Sleep (200)\n        DoEvents\n        \n        res = StartSerialComm(\"?\", \"COM4\")\n  \n        If InStr(res, \"Idle\") Then\n            Exit Do\n        End If\n    Loop\n \n    Worksheets(sht).Cells(5, 6).Value = res\n\n    MsgBox \"\u5897\u91cf\u904b\u8ee2\u5b8c\u4e86\", vbOKOnly\n\nEnd Sub\n\n\n\n'\u9023\u7d9a\u904b\u8ee2\nPrivate Sub CommandButton2_Click()\n    \n    Dim sht\n    Dim res\n    Dim pos_X, pos_Y\n    Dim G_CD As String\n    Dim ln_CNT\n    \n    \n    sht = ActiveSheet.Name\n    \n    Worksheets(sht).Range(\"E8:F2000\").ClearContents\n    \n    ln_CNT = 0\n    \n    Do\n        pos_X = Trim(Worksheets(sht).Cells(8 + ln_CNT, 3).Value)\n        pos_Y = Trim(Worksheets(sht).Cells(8 + ln_CNT, 4).Value)\n        \n        If pos_X = \"\" Or pos_Y = \"\" Then Exit Do\n        \n        G_CD = \"G90G0X\" &amp; pos_X &amp; \"Y\" &amp; pos_Y\n        Worksheets(sht).Cells(8 + ln_CNT, 5).Value = G_CD\n        \n        res = StartSerialComm(G_CD, \"COM4\")\n\n        Do\n            Sleep (500)\n            DoEvents\n        \n            res = StartSerialComm(\"?\", \"COM4\")\n  \n            If InStr(res, \"Idle\") Then\n                Exit Do\n            End If\n        Loop\n  \n        Worksheets(sht).Cells(8 + ln_CNT, 6).Value = res\n\n        DoEvents\n        ln_CNT = ln_CNT + 1\n        \n        If ln_CNT &gt;= 10 Then Exit Do\n    Loop\n    \n    MsgBox \"\u9023\u7d9a\u904b\u8ee2\u5b8c\u4e86(\" &amp; Trim(Str(ln_CNT)) &amp; \")\", vbOKOnly\n    \nEnd Sub<\/pre>\n<p><\/p>\n\n\n<p>\u3000\u30b7\u30ea\u30a2\u30eb\u9001\u4fe1\uff08RS-232C\uff09API\uff0c\u95a2\u6570\u5b9a\u7fa9\u90e8\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u3059\u3002VBA\u306e\u6a19\u6e96\u30e2\u30b8\u30e5\u30fc\u30eb\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n\n\n<pre class=\"height-set:true lang:default decode:true  \" title=\"VBA_SERIAL_API_FUNC_DEFINITION\">Option Explicit\n\nPrivate Declare Function CreateFile Lib \"kernel32\" Alias \"CreateFileA\" _\n   (ByVal lpFileName As String, _\n    ByVal dwDesiredAccess As Long, _\n    ByVal dwShareMode As Long, _\n    ByVal lpSecurityAttributes As Long, _\n    ByVal dwCreationDisposition As Long, _\n    ByVal dwFlagsAndAttributes As Long, _\n    ByVal hTemplateFile As Long) As Long\n\nPrivate Declare Sub CloseHandle Lib \"kernel32\" (ByVal hObject As Long)\n\nPrivate Declare Sub ReadFile Lib \"kernel32\" _\n   (ByVal hFile As Long, _\n    ByVal lpBuffer As String, _\n    ByVal nNumberOfBytesToRead As Long, _\n          lpNumberOfBytesRead As Long, _\n    ByVal lpOverlapped As Long)\n\nPrivate Declare Sub WriteFile Lib \"kernel32\" _\n   (ByVal hFile As Long, _\n    ByVal lpBuffer As String, _\n    ByVal nNumberOfBytesToWrite As Long, _\n          lpNumberOfBytesWritten As Long, _\n    ByVal lpOverlapped As Long)\n\nPrivate Declare Function SetCommState Lib \"kernel32\" (ByVal hFile As Long, ByRef lpDCB As DCB) As Long\nPrivate Declare Sub SetCommTimeouts Lib \"kernel32\" (ByVal hFile As Long, lpCommTimeouts As COMMTIMEOUTS)\n\n'SetCommState\nPrivate Type DCB\n    DCBlength As Long\n    BaudRate As Long\n    Fields As Long\n    wReserved As Integer\n    XonLim As Integer\n    XoffLim As Integer\n    ByteSize As Byte\n    Parity As Byte\n    StopBits As Byte\n    XonChar As Byte\n    XoffChar As Byte\n    ErrorChar As Byte\n    EofChar As Byte\n    EvtChar As Byte\n    wReserved1 As Integer\nEnd Type\n\n'SetCommTimeouts\nPrivate Type COMMTIMEOUTS\n    ReadIntervalTimeout As Long\n    ReadTotalTimeoutMultiplier As Long\n    ReadTotalTimeoutConstant As Long\n    WriteTotalTimeoutMultiplier As Long\n    WriteTotalTimeoutConstant As Long\nEnd Type\n\n\n'CreateFile\u30d1\u30e9\u30e1\u30fc\u30bf\u7528\u5b9a\u6570\nPrivate Const GENERIC_READ = (&amp;H80000000)\nPrivate Const GENERIC_WRITE = (&amp;H40000000)\nPrivate Const OPEN_EXISTING = 3\n\n\nPublic Function StartSerialComm(str_TX As String, com_port As String)\n    Dim comPort As String\n    Dim hFile As Long\n    Dim cs As DCB          'CommState\n    Dim ct As COMMTIMEOUTS 'CommTimeouts\n    Dim length As Long\n    Dim buf As String\n\n    comPort = com_port\n\n    'COM\u30dd\u30fc\u30c8\u30aa\u30fc\u30d7\u30f3\n    hFile = CreateFile(comPort, GENERIC_READ Or GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0)\n    If hFile = -1 Then\n        StartSerialComm = \"ERR_COM_OPEN\"\n        Exit Function\n    End If\n\n    'RS232C\u901a\u4fe1\u8a2d\u5b9a\n    cs.BaudRate = 9600\n    cs.ByteSize = 8\n    cs.Parity = 0\n    cs.StopBits = 0\n    cs.Fields = &amp;H3001\n    SetCommState hFile, cs\n\n    'RS232C\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u8a2d\u5b9a\n    ct.ReadIntervalTimeout = 1000\n    ct.ReadTotalTimeoutMultiplier = 1\n    ct.ReadTotalTimeoutConstant = 500\n    ct.WriteTotalTimeoutMultiplier = 1\n    ct.WriteTotalTimeoutConstant = 500\n    SetCommTimeouts hFile, ct\n\n    '\u9001\u4fe1\n    buf = str_TX + Chr(10)\n    WriteFile hFile, buf, Len(buf), length, 0\n\n    '\u53d7\u4fe1\n    buf = String(1024, vbNullChar)\n    ReadFile hFile, buf, Len(buf), length, 0\n\n    'COM\u30dd\u30fc\u30c8\u30af\u30ed\u30fc\u30ba\n    CloseHandle hFile\n\n    '\u53d7\u4fe1\u30c7\u30fc\u30bf\u306e\u30d1\u30fc\u30b9\n    buf = Replace(buf, vbNullChar, \"\")\n    buf = Replace(buf, Chr(10), \"\")\n    buf = Replace(buf, Chr(13), \"\")\n    \n    StartSerialComm = buf\n\nEnd Function<\/pre>\n<p>&nbsp;<\/p>\n\n\n<h2 class=\"has-text-color\" style=\"color:#000596\">\u307e\u3068\u3081<\/h2>\n\n\n\n<p>\u3000\u4f4d\u7f6e\u6c7a\u3081\u3068\u8a08\u6e2c\u306a\u3069\u3092\u7d44\u307f\u5408\u308f\u305b\u3066\u3001\u5b9f\u969b\u306b\u6d3b\u7528\u3059\u308b\u3053\u3068\u3082\u691c\u8a0e\u3057\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30a8\u30af\u30bb\u30eb\u3067\u30b9\u30c6\u30c3\u30d4\u30f3\u30b0\u30e2\u30fc\u30bf\u30fc\u4f4d\u7f6e\u6c7a\u3081 \u3000ARDUINO CNC-SHILD\u306e\u4f7f\u3044\u65b9\u3068\u30d1\u30bd\u30b3\u30f3\u304b\u3089ARDUINO\u306b\u30b7\u30ea\u30a2\u30eb\u901a\u4fe1\u3067G\u30b3\u30fc\u30c9\u3092\u9001\u4fe1\u3059\u308bGRBL\u306e\u4f7f\u3044\u65b9\u306b\u3064\u3044\u3066\u6295\u7a3f\u3057\u307e\u3057\u305f\u3002\u307e\u305f\u3001\u30d1\u30bd\u30b3\u30f3\u304b\u3089\u30a8\u30af\u30bb\u30ebVBA\u3092\u4f7f &hellip; <a href=\"https:\/\/kats-eye.net\/info\/2020\/03\/28\/excel-vba\/\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">\u30a8\u30af\u30bb\u30eb\u3067\u30b9\u30c6\u30c3\u30d4\u30f3\u30b0\u30e2\u30fc\u30bf\u30fc\u4f4d\u7f6e\u6c7a\u3081<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":3596,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5,98],"tags":[9,96,103],"_links":{"self":[{"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/posts\/3577"}],"collection":[{"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/comments?post=3577"}],"version-history":[{"count":30,"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/posts\/3577\/revisions"}],"predecessor-version":[{"id":3614,"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/posts\/3577\/revisions\/3614"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/media\/3596"}],"wp:attachment":[{"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/media?parent=3577"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/categories?post=3577"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/tags?post=3577"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}