{"id":1810,"date":"2015-05-12T08:26:08","date_gmt":"2015-05-11T23:26:08","guid":{"rendered":"http:\/\/excelwork.info\/excel\/?p=1810"},"modified":"2015-05-12T08:26:08","modified_gmt":"2015-05-11T23:26:08","slug":"funcinstr","status":"publish","type":"post","link":"https:\/\/excelwork.info\/excel\/funcinstr\/","title":{"rendered":"\u6587\u5b57\u5217\uff1a\u6587\u5b57\u5217\u3092\u691c\u7d22\u3057\u3066\u305d\u306e\u6700\u521d\u306e\u6587\u5b57\u4f4d\u7f6e\u3092\u8fd4\u3059\uff08InStr \u95a2\u6570,InStrB \u95a2\u6570\uff09"},"content":{"rendered":"<h2>InStr \u95a2\u6570\u30fbInStrB \u95a2\u6570\u306e\u4f7f\u3044\u65b9<\/h2>\n<br \/>\n<div class=\"m30-l\">\n<div class=\"kkbox\"><strong>\u3010\u66f8\u5f0f\u3011<\/strong><\/p>\n<p><em>result<\/em> = { <strong>InStr<\/strong> | <strong>InStrB<\/strong> } ( [ <em>start<\/em> ], <em>string1<\/em>, <em>string2<\/em> [, <em>compare<\/em> ] )<\/p>\n<\/div>\n<br \/>\n<h3>\u5f15\u6570\u30fb\u623b\u308a\u5024<\/h3>\n<ul style=\"margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0;\">\n<li>start&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u691c\u7d22\u306e\u958b\u59cb\u4f4d\u7f6e\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u7701\u7565\u3059\u308b\u3068\u3001\u5148\u982d\u306e\u6587\u5b57\u304b\u3089\u691c\u7d22\u3055\u308c\u307e\u3059\u3002\u3082\u3057\u3001<em>start<\/em> \u306b\u3001Null \u5024\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u5834\u5408\u306f\u3001\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3059\u3002\u7701\u7565\u53ef\u80fd\u3002\u305f\u3060\u3057\u3001\u5f15\u6570 <em>compare<\/em> \u3092\u6307\u5b9a\u3057\u305f\u5834\u5408\u306f\u3001<em>start<\/em> \u3092\u7701\u7565\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093\u3002<\/li>\n<li>string1&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u691c\u7d22\u5bfe\u8c61\u306e\u6587\u5b57\u5217\u30fb\u6587\u5b57\u5217\u5f0f\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<li>string2&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u5f15\u6570 <em>string1<\/em> \u5185\u3067\u3001\u691c\u7d22\u3059\u308b\u6587\u5b57\u5217\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<li>compare&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u6587\u5b57\u5217\u306e\u6bd4\u8f03\u30e2\u30fc\u30c9\uff08-1,0,1\uff09\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u7701\u7565\u6642\u306f\u3001\u300cOption Compare \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u300d\u306e\u8a2d\u5b9a\u306b\u3088\u308a\u6bd4\u8f03\u30e2\u30fc\u30c9\u304c\u6c7a\u307e\u308a\u307e\u3059\u3002<br \/><br \/>\n<table>\n<tr>\n<td align = \"center\"><strong>\u5024<\/strong><\/td>\n<td align = \"center\"><strong>\u5b9a\u6570<\/strong><\/td>\n<td align = \"center\"><strong>\u5185\u5bb9<\/strong><\/td>\n<\/tr>\n<tr>\n<td align = \"center\">-1<\/td>\n<td>vbUseCompareOption<\/td>\n<td><a href=\"https:\/\/excelwork.info\/excel\/optioncompare\/\">Option Compare \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8<\/a>\u306e\u8a2d\u5b9a\u3092\u4f7f\u7528\u3057\u3066\u6bd4\u8f03<\/td>\n<\/tr>\n<tr>\n<td align = \"center\">0<\/td>\n<td>vbBinaryCompare<\/td>\n<td>\u30d0\u30a4\u30ca\u30ea\u30e2\u30fc\u30c9\u306e\u6bd4\u8f03<\/td>\n<\/tr>\n<tr>\n<td align = \"center\">1<\/td>\n<td>vbTextCompare<\/td>\n<td>\u30c6\u30ad\u30b9\u30c8\u30e2\u30fc\u30c9\u306e\u6bd4\u8f03\uff08\u5927\u6587\u5b57\u30fb\u5c0f\u6587\u5b57\u3092\u540c\u4e00\u8996\uff09<\/td>\n<\/tr>\n<tr>\n<td align = \"center\">2<\/td>\n<td>vbDatabaseCompare<\/td>\n<td>Microsoft Access \u306e\u5834\u5408\u306e\u307f\u6709\u52b9<\/td>\n<\/tr>\n<\/table>\n<p><br \/>\n<\/li>\n<li>result&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u3042\u308b\u6587\u5b57\u5217\uff08<em>string1<\/em>\uff09\u306e\u4e2d\u304b\u3089\u6307\u5b9a\u3057\u305f\u6587\u5b57\u5217\uff08<em>string2<\/em>\uff09\u3092\u691c\u7d22\u3057\u3001\u6700\u521d\u306b\u898b\u3064\u304b\u3063\u305f\u6587\u5b57\u4f4d\u7f6e\u3002\uff08 \u203b <strong>InStr<\/strong> \u306e\u5834\u5408\u306f\u3001\u5148\u982d\u304b\u3089\u305d\u306e\u4f4d\u7f6e\u307e\u3067\u306e<span class=\"red\">\u6587\u5b57\u6570<\/span>\u3002<strong>InStrB<\/strong> \u306e\u5834\u5408\u306f\u3001\u5148\u982d\u304b\u3089\u305d\u306e\u4f4d\u7f6e\u307e\u3067\u306e<span class=\"red\">\u30d0\u30a4\u30c8\u6570<\/span>\u3002\uff09<br \/><br \/>\n<table>\n<tr>\n<td align = \"center\"><strong>\u5185\u5bb9<\/strong><\/td>\n<td align = \"center\"><strong>\u623b\u308a\u5024<\/strong><\/td>\n<\/tr>\n<tr>\n<td><em>string1<\/em> \u304c\u9577\u3055 0 \u306e\u6587\u5b57\u5217\uff08&#8221;&#8221;\uff09<\/td>\n<td>0<\/td>\n<\/tr>\n<tr>\n<td><em>string1<\/em> \u304c Null \u5024<\/td>\n<td>Null \u5024<\/td>\n<\/tr>\n<tr>\n<td><em>string2<\/em> \u304c\u9577\u3055 0 \u306e\u6587\u5b57\u5217\uff08&#8221;&#8221;\uff09<\/td>\n<td><em>start<\/em><\/td>\n<\/tr>\n<tr>\n<td><em>string2<\/em> \u304c Null \u5024<\/td>\n<td>Null \u5024<\/td>\n<\/tr>\n<tr>\n<td><em>string2<\/em> \u304c\u898b\u3064\u304b\u3089\u306a\u3044\u3068\u304d<\/td>\n<td>0<\/td>\n<\/tr>\n<tr>\n<td><em>string2<\/em> \u304c <em>string1<\/em> \u5185\u3067\u898b\u3064\u304b\u3063\u305f\u3068\u304d<\/td>\n<td>\u898b\u3064\u304b\u3063\u305f\u6587\u5b57\u5217\u306e\u4f4d\u7f6e<br \/>InStr \u306f\u3001\u6587\u5b57\u6570\u3001InStrB \u306f\u30d0\u30a4\u30c8\u6570<\/td>\n<\/tr>\n<tr>\n<td><em>start<\/em> \u306e\u5024\u304c <em>string1<\/em> \u306e\u6587\u5b57\u6570\u3092\u8d85\u3048\u308b\u6642<\/td>\n<td>0<\/td>\n<\/tr>\n<\/table>\n<p><br \/>\n<\/li>\n<\/ul>\n<\/div>\n<br \/><br \/>\n<h2>InStr \u95a2\u6570\u30fbInStrB \u95a2\u6570 \u306e\u4f7f\u7528\u4f8b<\/h2>\n<div class=\"m30-l\">\n<h3 id=\"vba_sample\">\u30b5\u30f3\u30d7\u30ebVBA\u30bd\u30fc\u30b9<\/h3>\n<pre class=\"lang:vb mark:0 decode:true \" title=\"InStr \u95a2\u6570\u30fbInStrB \u95a2\u6570\u306e\u4f7f\u7528\u4f8b\" data-url=\"http:\/\/example.co.jp\" >\r\n\r\n\u3000\r\nSub Sample_InStr()\r\n\r\n    Dim str1, str2, str3\r\n    Dim s1, s2, s3\r\n    \r\n    str1 = \"abcdeABCDE\"\r\n    str2 = \"\u3042\u3044\u3046\u3048\u304a\u304b\u304d\u304f\u3051\u3053\"\r\n    str3 = \"\u3053\u3093\u306b\u3061\u306f! Hello\uff01\uff01\"\r\n    \r\n    Debug.Print InStr(1, str1, \"ABC\", vbBinaryCompare)      '6\r\n    Debug.Print InStr(1, str1, \"ABC\", vbTextCompare)        '1\r\n    Debug.Print InStrB(1, str1, \"ABC\", vbBinaryCompare)     '11\r\n    Debug.Print InStrB(1, str1, \"ABC\", vbTextCompare)       '11\r\n    \r\n    Debug.Print InStr(2, str2, \"\u304f\u3051\", vbBinaryCompare)     '8\r\n    Debug.Print InStr(2, str2, \"\u304f\u3051\", vbTextCompare)       '8\r\n    Debug.Print InStrB(2, str2, \"\u304f\u3051\", vbBinaryCompare)    '15\r\n    Debug.Print InStrB(2, str2, \"\u304f\u3051\", vbTextCompare)      '15\r\n    \r\n    Debug.Print InStr(str3, \"hello\")                        '0 \uff08\u203b\u5f15\u6570\u7701\u7565\uff09\r\n    Debug.Print InStrB(str3, \"hello\")                       '0 \uff08\u203b\u5f15\u6570\u7701\u7565\uff09\r\n    \r\n    Debug.Print InStr(4, str3, \"hello\", vbTextCompare)      '8\r\n    Debug.Print InStrB(4, str3, \"hello\", vbTextCompare)     '0\r\n\r\nEnd Sub\r\n\u3000\r\n\r\n<\/pre>\n<br \/>\n<h3>\u5b9f\u884c\u7d50\u679c<\/h3>\n<p><a href=\"https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/05\/func_instr.jpg?ssl=1\" rel=\"lightbox[1810]\"><img loading=\"lazy\" src=\"https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/05\/func_instr.jpg?resize=400%2C391&#038;ssl=1\" alt=\"InStr \u95a2\u6570\u3000\u4f8b\" width=\"400\" height=\"391\" class=\"alignnone size-medium wp-image-1814\" srcset=\"https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/05\/func_instr.jpg?resize=400%2C391&amp;ssl=1 400w, https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/05\/func_instr.jpg?resize=580%2C567&amp;ssl=1 580w, https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/05\/func_instr.jpg?w=602&amp;ssl=1 602w\" sizes=\"(max-width: 400px) 100vw, 400px\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<br \/><\/div>\n<br \/><br \/>\n","protected":false},"excerpt":{"rendered":"<p>InStr \u95a2\u6570\u30fbInStrB \u95a2\u6570\u306e\u4f7f\u3044\u65b9 \u3010\u66f8\u5f0f\u3011 result = { I &#8230; <\/p>\n","protected":false},"author":1,"featured_media":1821,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"amp_status":"","spay_email":"","jetpack_publicize_message":"\u6587\u5b57\u5217\uff1a\u6587\u5b57\u5217\u3092\u691c\u7d22\u3057\u3066\u305d\u306e\u6700\u521d\u306e\u6587\u5b57\u4f4d\u7f6e\u3092\u8fd4\u3059\uff08InStr \u95a2\u6570,InStrB \u95a2\u6570\uff09 http:\/\/wp.me\/p4Ye9i-tc"},"categories":[37],"tags":[219,220,63,38,221],"jetpack_featured_media_url":"https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/05\/func_instr-400x3911.jpg?fit=400%2C391&ssl=1","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4Ye9i-tc","_links":{"self":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/1810"}],"collection":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/comments?post=1810"}],"version-history":[{"count":6,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/1810\/revisions"}],"predecessor-version":[{"id":1820,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/1810\/revisions\/1820"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/media\/1821"}],"wp:attachment":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/media?parent=1810"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/categories?post=1810"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/tags?post=1810"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}