Private Sub Command1_Click()
s = Text1
For i = 1 To Len(s)
c = Mid(s, i, 1)
If c >= "A" And c <= "Z" Then
c = Chr(Asc(c) + 32)
Else
If c >= "a" And c <= "z" Then c = Chr(Asc(c) - 32)
End If
Mid(s, i, 1) = c
Next i
Text2 = s
End Sub
比如通过text1输入字符串,并且转换后由text1输出:
Private Sub Command1_Click()
s = Text1.Text
l = Len(s)
For i = 1 To l
t = Mid(s, i, 1)
If Asc(t) >= 65 And Asc(t) <= 90 Then
r = r & LCase(t)
ElseIf Asc(t) >= 97 And Asc(t) <= 122 Then
r = r & UCase(t)
End If
Next i
Text1.Text = r
End Sub
LCase():是返回小写字母函数
UCase():是返回大写字母函数
例如:字符是:ABcDef
LCase("ABcDef") 的返回值是:ABCDEF
UCase("ABcDef") 的返回值是:abcdef
LCase(字符)大写变小写
UCase(字符)小写变大写
Private Sub Command1_Click()
s = ""
t = Text1.Text
For i = 0 To Len(Text1.Text) - 1
t = Mid(Text1.Text, i + 1, Len(Text1.Text) - 1)
a = Mid(t, 1, 1)
If Asc(a) >= 65 And Asc(a) <= 90 Then
s = s & LCase(a)
Else
s = s & UCase(a)
End If
Next i
Text1.Text = s
End Sub