添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
public static int InStr (int StartPos, string? String1, string? String2, Microsoft.VisualBasic.CompareMethod Compare = Microsoft.VisualBasic.CompareMethod.Binary);
public static int InStr (int Start, string? String1, string? String2, Microsoft.VisualBasic.CompareMethod Compare = Microsoft.VisualBasic.CompareMethod.Binary);
public static int InStr (int StartPos, string String1, string String2, Microsoft.VisualBasic.CompareMethod Compare = Microsoft.VisualBasic.CompareMethod.Binary);
public static int InStr (int Start, string String1, string String2, Microsoft.VisualBasic.CompareMethod Compare = Microsoft.VisualBasic.CompareMethod.Binary);
static member InStr : int * string * string * Microsoft.VisualBasic.CompareMethod -> int
static member InStr : int * string * string * Microsoft.VisualBasic.CompareMethod -> int
Public Function InStr (StartPos As Integer, String1 As String, String2 As String, Optional Compare As CompareMethod = Microsoft.VisualBasic.CompareMethod.Binary) As Integer
Public Function InStr (Start As Integer, String1 As String, String2 As String, Optional Compare As CompareMethod = Microsoft.VisualBasic.CompareMethod.Binary) As Integer

本例使用 InStr 函数返回一个字符串在另一个字符串中的第一个匹配项的位置。

' String to search in.
Dim searchString As String = "XXpXXpXXPXXP"
' Search for "P".
Dim searchChar As String = "P"
Dim testPos As Integer
' A textual comparison starting at position 4. Returns 6.
testPos = InStr(4, searchString, searchChar, CompareMethod.Text)
' A binary comparison starting at position 1. Returns 9.
testPos = InStr(1, SearchString, SearchChar, CompareMethod.Binary)
' If Option Compare is not set, or set to Binary, return 9.
' If Option Compare is set to Text, returns 3.
testPos = InStr(searchString, searchChar)
' Returns 0.
testPos = InStr(1, searchString, "W")
    	

通常, InStr 函数在分析字符串时使用。

InStrB以前版本的 Visual Basic 中的 函数返回字节数,而不是字符位置。 它主要用于转换双字节字符集 (DBCS) 应用程序中的字符串。 所有 Visual Basic 2005 字符串都在 Unicode 中, InStrB 不再受支持。

Compare 参数的设置是:

返回的常量 Value
  • InStrRev(String, String, Int32, CompareMethod)
  • StrComp(String, String, CompareMethod)
  • ArgumentException
  • 字符串 (Visual Basic)
  • 字符串介绍 (Visual Basic)
  • Option Compare 语句
  • public static int InStr (string? String1, string? String2, Microsoft.VisualBasic.CompareMethod Compare = Microsoft.VisualBasic.CompareMethod.Binary);
    public static int InStr (string String1, string String2, Microsoft.VisualBasic.CompareMethod Compare = Microsoft.VisualBasic.CompareMethod.Binary);
    static member InStr : string * string * Microsoft.VisualBasic.CompareMethod -> int
    Public Function InStr (String1 As String, String2 As String, Optional Compare As CompareMethod = Microsoft.VisualBasic.CompareMethod.Binary) As Integer

    本例使用 InStr 函数返回一个字符串在另一个字符串中的第一个匹配项的位置。 在第一个示例中,搜索从第四个字符开始,并返回下一个小写“p”,因为 CompareMethodText ,因此不区分大小写。 无论起始位置如何,该位置始终相对于字符串的开头。

    ' String to search in.
    Dim searchString As String = "XXpXXpXXPXXP"
    ' Search for "P".
    Dim searchChar As String = "P"
    Dim testPos As Integer
    ' A textual comparison starting at position 4. Returns 6.
    testPos = InStr(4, searchString, searchChar, CompareMethod.Text)
    ' A binary comparison starting at position 1. Returns 9.
    testPos = InStr(1, SearchString, SearchChar, CompareMethod.Binary)
    ' If Option Compare is not set, or set to Binary, return 9.
    ' If Option Compare is set to Text, returns 3.
    testPos = InStr(searchString, searchChar)
    ' Returns 0.
    testPos = InStr(1, searchString, "W")
        	

    通常, InStr 函数在分析字符串时使用。

    InStrB以前版本的 Visual Basic 中的 函数返回字节数,而不是字符位置。 它主要用于转换双字节字符集 (DBCS) 应用程序中的字符串。 所有 Visual Basic 2005 字符串都在 Unicode 中, InStrB 不再受支持。

    Compare 参数的设置是:

    返回的常量 Value
  • InStrRev(String, String, Int32, CompareMethod)
  • StrComp(String, String, CompareMethod)
  • ArgumentException
  • 字符串 (Visual Basic)
  • 字符串介绍 (Visual Basic)
  • Option Compare 语句
  •