1cdf0e10cSrcweir<?xml version="1.0" encoding="UTF-8"?> 2cdf0e10cSrcweir 3d33d0967SAndrew Rist<!--*********************************************************** 4cdf0e10cSrcweir * 5d33d0967SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 6d33d0967SAndrew Rist * or more contributor license agreements. See the NOTICE file 7d33d0967SAndrew Rist * distributed with this work for additional information 8d33d0967SAndrew Rist * regarding copyright ownership. The ASF licenses this file 9d33d0967SAndrew Rist * to you under the Apache License, Version 2.0 (the 10d33d0967SAndrew Rist * "License"); you may not use this file except in compliance 11d33d0967SAndrew Rist * with the License. You may obtain a copy of the License at 12cdf0e10cSrcweir * 13d33d0967SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 14cdf0e10cSrcweir * 15d33d0967SAndrew Rist * Unless required by applicable law or agreed to in writing, 16d33d0967SAndrew Rist * software distributed under the License is distributed on an 17d33d0967SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 18d33d0967SAndrew Rist * KIND, either express or implied. See the License for the 19d33d0967SAndrew Rist * specific language governing permissions and limitations 20d33d0967SAndrew Rist * under the License. 21cdf0e10cSrcweir * 22d33d0967SAndrew Rist ***********************************************************--> 23d33d0967SAndrew Rist 24cdf0e10cSrcweir<helpdocument version="1.0"> 25cdf0e10cSrcweir<meta> 26cdf0e10cSrcweir<topic id="textsbasicshared03120401xml" indexer="include" status="PUBLISH"> 27cdf0e10cSrcweir<title id="tit" xml-lang="en-US">InStr Function [Runtime]</title> 28cdf0e10cSrcweir<filename>/text/sbasic/shared/03120401.xhp</filename> 29cdf0e10cSrcweir</topic> 30cdf0e10cSrcweir</meta> 31cdf0e10cSrcweir<body> 32cdf0e10cSrcweir<section id="instr"> 33e91968a5Smseidel<bookmark xml-lang="en-US" branch="index" id="bm_id3155934"> 34e91968a5Smseidel<bookmark_value>InStr function</bookmark_value> 35cdf0e10cSrcweir</bookmark> 36*d976dd13Smseidel<paragraph role="heading" id="hd_id3155934" xml-lang="en-US" level="1" l10n="U"><link href="text/sbasic/shared/03120401.xhp" name="InStr Function [Runtime]">InStr Function [Runtime]</link></paragraph> 37*d976dd13Smseidel<paragraph role="paragraph" id="par_id3153990" xml-lang="en-US" l10n="U">Returns the position of a string within another string.</paragraph> 38cdf0e10cSrcweir</section> 39*d976dd13Smseidel<paragraph role="paragraph" id="par_id3147303" xml-lang="en-US" l10n="U">The Instr function returns the position at which the match was found. If the string was not found, the function returns 0.</paragraph> 40*d976dd13Smseidel<paragraph role="heading" id="hd_id3145090" xml-lang="en-US" level="2" l10n="U">Syntax:</paragraph> 41*d976dd13Smseidel<paragraph role="code" id="par_id3146957" xml-lang="en-US" l10n="U">InStr ([Start As Long,] Text1 As String, Text2 As String[, Compare])</paragraph> 42*d976dd13Smseidel<paragraph role="heading" id="hd_id3148538" xml-lang="en-US" level="2" l10n="U">Return value:</paragraph> 43*d976dd13Smseidel<paragraph role="paragraph" id="par_id3149763" xml-lang="en-US" l10n="U">Integer</paragraph> 44*d976dd13Smseidel<paragraph role="heading" id="hd_id3148473" xml-lang="en-US" level="2" l10n="U">Parameters:</paragraph> 45*d976dd13Smseidel<paragraph role="paragraph" id="par_id3153126" xml-lang="en-US" l10n="CHG"><emph>Start:</emph> A numeric expression that marks the position in a string where the search for the specified substring starts. If you omit this parameter, the search starts at the first character of the string. The maximum allowed value is 65535.<comment>UFI: see #i17928#</comment></paragraph> 46*d976dd13Smseidel<paragraph role="paragraph" id="par_id3145609" xml-lang="en-US" l10n="U"><emph>Text1:</emph> The string expression that you want to search.</paragraph> 47*d976dd13Smseidel<paragraph role="paragraph" id="par_id3147559" xml-lang="en-US" l10n="U"><emph>Text2:</emph> The string expression that you want to search for.</paragraph> 48*d976dd13Smseidel<paragraph role="paragraph" id="par_id3154758" xml-lang="en-US" l10n="CHG"><emph>Compare:</emph> Optional numeric expression that defines the type of comparison. The value of this parameter can be 0 or 1. The default value of 1 specifies a text comparison that is not case-sensitive. The value of 0 specifies a binary comparison that is case-sensitive.<comment>UFI: fixes #i17929#</comment></paragraph> 49*d976dd13Smseidel<paragraph role="paragraph" id="par_id3153361" xml-lang="en-US" l10n="U">To avoid a run-time error, do not set the Compare parameter if the first return parameter is omitted.</paragraph> 50cdf0e10cSrcweir<embed href="text/sbasic/shared/00000003.xhp#errorcode"/> 51cdf0e10cSrcweir<embed href="text/sbasic/shared/00000003.xhp#err5"/> 52*d976dd13Smseidel<paragraph role="heading" id="hd_id3154366" xml-lang="en-US" level="2" l10n="U">Example:</paragraph> 53*d976dd13Smseidel<paragraph role="code" id="par_id3154217" xml-lang="en-US" l10n="U">Sub ExamplePosition</paragraph> 54*d976dd13Smseidel<paragraph role="code" id="par_id3154685" xml-lang="en-US" l10n="U">Dim sInput As String</paragraph> 55*d976dd13Smseidel<paragraph role="code" id="par_id3151042" xml-lang="en-US" l10n="U">Dim iPos as Integer</paragraph> 56*d976dd13Smseidel<paragraph role="code" id="par_id3144760" xml-lang="en-US" l10n="CHG">sInput = "Office"</paragraph> 57*d976dd13Smseidel<paragraph role="code" id="par_id3154125" xml-lang="en-US" l10n="CHG">iPos = Instr(sInput,"c")</paragraph> 58*d976dd13Smseidel<paragraph role="code" id="par_id3145173" xml-lang="en-US" l10n="U">print iPos</paragraph> 59*d976dd13Smseidel<paragraph role="code" id="par_id3145786" xml-lang="en-US" l10n="U">end sub</paragraph> 60cdf0e10cSrcweir</body> 61cdf0e10cSrcweir</helpdocument> 62