我真的建议您删除旧的 VB6 函数并使用更高级的 NET 等效函数。
string.TrimStart
string.TrimEnd
string.Trim
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox2.Text = TextBox1.Text.TrimStart(Nothing)
End Sub
编辑:相反,(在不同的答案中查看您的评论)如果您想从字符串中提取最后 3 个字符,则使用的方法是string.Substring和属性string.Length
Dim original = TextBox1.Text
Dim last3 = original
' be sure to have at least 3 chars before doing substring math
If last3.Length > 3 Then
last3 = original.Substring(original.Length - 3, 3)
End If
TextBox2.Text = last3