[求助][讨论]可以回答非所问吗?我不会
从键盘上输入两个字符串,分别保存在变量str1、str2中。确定第二个字符串在第一个字符串中起始位置的函数是
A) Left B) Mid C) String D) Instr
这道题选什么呀?说了可以解释一下吗?谢谢~~~~
left返回一个字符串,其中包含从某个字符串左端开始的指定数量的字符。
Public Shared Function Left( _ ByVal Str As String, _ ByVal Length As Integer _) As String
[此贴子已经被作者于2004-12-01 23:18:32编辑过]

从一个字符串返回包含指定数量字符的字符串。
Public Shared Function Mid( _ ByVal Str As String, _ ByVal Start As Integer, _ Optional ByVal Length As Integer _) As String

InStrRev 函数 | Option Compare 语句 | StrComp 函数 |
返回一个整数,该整数指定一个字符串在另一个字符串中的第一个匹配项的起始位置。
Public Shared Function InStr(_ ByVal Start As Integer, _ ByVal String1 As String, _ ByVal String2 As String, _ Optional ByVal Compare As Microsoft.VisualBasic.CompareMethod _) As Integer
compare 参数设置包括:
| 常数 | 值 | 说明 |
|---|---|---|
| Binary | 0 | 执行二进制比较 |
| Text | 1 | 执行文本比较 |
| 如果 | InStr 返回 |
|---|---|
| String1 为零长度或 Nothing | 0 |
| String2 为零长度或 Nothing | start |
| 未找到 String2 | 0 |
| 在 String1 中找到 String2 | 匹配开始的位置 |
| Start > String2 | 0 |
| 异常类型 | 错误号 | 条件 |
|---|---|---|
| 5 | Start < 1。 |
本例使用 InStr 函数返回一个字符串在另一个字符串中的第一个匹配项的位置。
Dim SearchString, SearchChar As StringDim MyPos As IntegerSearchString ="XXpXXpXXPXXP" ' String to search in.SearchChar = "P" ' Search for "P".' A textual comparison starting at position 4. Returns 6.MyPos =InStr(4,SearchString,SearchChar,CompareMethod.Text)' A binary comparison starting at position 1. Returns 9.MyPos =InStr(1,SearchString,SearchChar,CompareMethod.Binary)' Comparison is binary by default (last argument is omitted).MyPos =InStr(SearchString,SearchChar)' Returns 9.MyPos =InStr(1,SearchString,"W")' Returns 0.
InStrRev 函数 | Option Compare 语句 | StrComp 函数 |
