VBScript InStr လုပ်ဆောင်ချက်
❮ VBScript အကိုးအကားကို အပြီးသတ်ပါ။
InStr လုပ်ဆောင်ချက်သည် နောက်တစ်ခုအတွင်းရှိ စာကြောင်းတစ်ခု၏ ပထမဆုံးဖြစ်ပေါ်မှု အနေအထားကို ပြန်ပေးသည်။
InStr လုပ်ဆောင်ချက်သည် အောက်ပါတန်ဖိုးများကို ပြန်ပေးနိုင်သည်။
- string1 သည် "" ဖြစ်ပါက - InStr သည် 0 ကို ပြန်ပေးသည်။
- string1 သည် Null ဖြစ်ပါက - InStr သည် Null ဖြစ်သွားသည်။
- string2 သည် "" ဖြစ်ပါက - InStr သည် စတင်သည်။
- string2 သည် Null ဖြစ်ပါက - InStr သည် Null ဖြစ်သွားသည်။
- string2 ကို ရှာမတွေ့ပါက - InStr သည် 0 ကို ပြန်ပေးသည်။
- string2 ကို string1 တွင်တွေ့ရှိပါက - InStr သည် ကိုက်ညီသည့် အနေအထားကို ပြန်ပေးသည်။
- start > Len(string1) - InStr က 0 ပြန်တက်လာရင်
အကြံပြုချက်- InStrRev လုပ်ဆောင်ချက်ကိုလည်း ကြည့်ရှုပါ ။
အထားအသို
InStr([start,]string1,string2[,compare])
Parameter | Description |
---|---|
start | Optional. Specifies the starting position for each search. The search begins at the first character position (1) by default. This parameter is required if compare is specified |
string1 | Required. The string to be searched |
string2 | Required. The string expression to search for |
compare | Optional. Specifies the string comparison to use.
Default is 0 Can have one of the following values:
|
ဥပမာများ
ဥပမာ ၁
<%
txt="This is a beautiful day!"
response.write(InStr(txt,"beautiful"))
%>
အထက်ဖော်ပြပါ ကုဒ်၏ အထွက်သည်-
11
ဥပမာ ၂
ကွဲပြားခြားနားသော စတင်သည့်နေရာများကို အသုံးပြု၍ စာလုံး "i" ကို ရှာခြင်း-
<%
txt="This is a beautiful day!"
response.write(InStr(1,txt,"i") & "<br />")
response.write(InStr(7,txt,"i") & "<br />")
%>
အထက်ဖော်ပြပါ ကုဒ်၏ အထွက်သည်-
3
16
ဥပမာ ၃
အက္ခရာ "t" ကို စာသား၊ နှင့် ဒွိနှိုင်းဖြင့် ရှာဖွေခြင်း-
<%
txt="This is a beautiful day!"
response.write(InStr(1,txt,"t",1) & "<br />")
response.write(InStr(1,txt,"t",0) & "<br />")
%>
အထက်ဖော်ပြပါ ကုဒ်၏ အထွက်သည်-
1
15
❮ VBScript အကိုးအကားကို အပြီးသတ်ပါ။