Public a As Integer
Private Sub Command1_Click()
If a Then
Command1.Caption = "已经点过了"
Else
a = a + 1
Dim str1 As String
Dim str2 As String
Dim str3 As String
str1 = "  abcdefgh  "
Print "*" + str1 + "*"
Print "*" + LTrim(str1) + "*", "  删除左边空格"
Print "*" + RTrim(str1) + "*", "  删除右边空格"
Print "*" + Trim(str1) + "*", "  删除所有空格"
Print "  "
'字符串删除空白函数
str2 = "HDSFHSHFSHS"
Print str2
Print Left(str2, 3), "  从左边截取,3"
Print Right(str2, 3), "  从右边截取,3"
Print Mid(str2, 3, 2), "  从中间截取,3,2"
Print "  "
vba计算字符串长度'字符串截取函数
str3 = "ahdbhabdahdbah"
Print str3
Print Len(str3), "  字符串长度"
Print "  "
'字符串长度测试函数
Print String(5, 97), "  ASCII代码"
Print "  "
'string$(n,字符串)
Print " 1234567890"
Print "*" + Space(10) + "*", "  空格函数"
Print "  "
'空格函数
Print InStr("abcdefcdgh", "cd"), "  字符串匹配"
Print InStr(4, "abcdeCDfcdgh", "cd"), "  区分大小写"  '4 指开始位置 0 区分大小写
Print InStr(4, "abcdeCDfcdgh", "cd", 1), "  不区分大小写"  '1 不区分大小写
Print "  "
'字符串匹配函数
Print UCase("adgsadahda"), "  小写变大写"
Print LCase("SYUDGFSFGH"), "  大写变小写"
Print "  "
'字母大小写转换
Dim str4 As String, str5 As String
str4 = "hdshagfajja"
str5 = "HBH"
Print str4
Print str5
Mid(str4, 4, 2) = str5  '4 指插入位置,2 指插入个数
Print str4, "  插入字符串"
'字符串插入语句
End If
End Sub
Private Sub Form_Load()
a = 0
End Sub

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。