Microsoft.VisualBasic 程序集: Microsoft.VisualBasic.Core.dll Source: Strings.vb 返回一个字符串,该字符串包含从某字符串左侧算起的指定数量的字符。 C# publicstaticstringLeft(string? str,intLength); 参数 str String 必需。 一个String表达式,从中返回最左侧的那些字符。
DimAnyString, MyStr AnyString ="Hello World"' Define string.MyStr = Left(AnyString,1)' Returns "H".MyStr = Left(AnyString,7)' Returns "Hello W".MyStr = Left(AnyString,20)' Returns "Hello World". 另請參閱 函式(Visual Basic for Applications) ...
下表列出 Visual Basic 在Microsoft.VisualBasic.Strings類別中提供的函式,用於搜尋和操作字串。 這些函式可視為 Visual Basic 內建函式;也就是說,您無須以類別的明確成員呼叫,如下列範例所示。 其他方法和互補方法 (在某些情況下) 都會在System.String類別中提供。
Visual Basic 早期版本中的 LeftB 函数返回字节形式(而不是字符形式)的字符串。它主要用于在双字节字符集 (DBCS) 应用程序中转换字符串。当前所有 Visual Basic 字符串均采用 Unicode 的形式,不再支持 LeftB。 示例 此示例演示返回给定 String 的子字符串的 Left 函数的用法。在具有 Left 属性的类中,可能需要对...
名前空間: Microsoft.VisualBasic アセンブリ: Microsoft.VisualBasic.Core.dll ソース: Strings.vb 指定された文字数を含む文字列を返します。 C# コピー public static string Left (string? str, int Length); パラメーター str String 必須です。 左端の文字が返される String 型の式。
Dim S As String = "Database" ' The following statement sets S to a new string containing "Data". S = Microsoft.VisualBasic.Left(S, 4) 別のコンポーネントで作成された文字列には、先頭または末尾に空白が埋め込まれていることがあります。 このような文字列を受け取った場合に、Trim、...
這個範例會示範使用 Left 函式,以傳回指定 String 的子字串。在具有 Left 屬性的類別中,可能必須完整限定 Left 函式。VB 複製 Dim TestString As String = "Hello World!" ' Returns "Hello". Dim subString As String = Microsoft.VisualBasic.Left(TestString, 5) ...
Namespace: Microsoft.VisualBasic Assembly: Microsoft.VisualBasic.Core.dll Source: Strings.vb Returns a string containing a specified number of characters from the left side of a string. C# Copy public static string Left(string? str, int Length); Parameters str String Required. String ...
substr=Left("Visual Basic",3) 则 substr="Vis" 6.Right[$](字符串,字符个数) 用于返回“字符串”最右边的长度为“字符个数”的字符串。 例如, Dim substr As String substr=Right("Visual Basic",3) 则 substr="sic" 7.Mid[$](字符串,起始位置,[字符个数]) 用于返回一个子字符串。 说明: (1...
按Alt+F11 打开 Visual Basic 编辑器。 在“插入”菜单上,单击“模块”。 在新模块工作表中键入以下宏。 VB SubString_Len()' Sets MyString.MyString = InputBox("Enter some text.")' Displays length of string.MsgBox Prompt:="The length of the string is "& _ Len(MyString) &" characters."End...