【求解】VB 同时转换字符串中字母的大小写 怎么写程序
答案:3 悬赏:60 手机版
解决时间 2021-04-15 07:48
- 提问者网友:温旧梦泪无声
- 2021-04-14 08:09
【求解】VB 同时转换字符串中字母的大小写 怎么写程序
最佳答案
- 五星知识达人网友:人類模型
- 2021-04-14 09:13
Private Sub Command1_Click()
Dim a As String
a = "Hellow Word!"
Dim i As Integer, x As Byte
For i = 1 To Len(a)
x = Asc(Mid(a, i, 1))
If (x >= 65 And x <= 90) Then
x = x + 32
Mid(a, i, 1) = Chr(x)
ElseIf (x >= 97 And x <= 122) Then
x = x - 32
Mid(a, i, 1) = Chr(x)
End If
Next
MsgBox a
End Sub
Dim a As String
a = "Hellow Word!"
Dim i As Integer, x As Byte
For i = 1 To Len(a)
x = Asc(Mid(a, i, 1))
If (x >= 65 And x <= 90) Then
x = x + 32
Mid(a, i, 1) = Chr(x)
ElseIf (x >= 97 And x <= 122) Then
x = x - 32
Mid(a, i, 1) = Chr(x)
End If
Next
MsgBox a
End Sub
全部回答
- 1楼网友:詩光轨車
- 2021-04-14 10:09
Private Sub Command1_Click()
Dim s As String
Dim s1 As String
s = InputBox("请你输入一段字母")
Print s
For i = 1 To Len(s)
Select Case Mid(s, i, 1)
Case "A" To "Z"
s1 = s1 + LCase(Mid(s, i, 1))
Case "a" To "z"
s1 = s1 + UCase(Mid(s, i, 1))
Case Else
s1 = s1 + Mid(s, i, 1)
End Select
Next i
Print s1
End Sub
Dim s As String
Dim s1 As String
s = InputBox("请你输入一段字母")
Print s
For i = 1 To Len(s)
Select Case Mid(s, i, 1)
Case "A" To "Z"
s1 = s1 + LCase(Mid(s, i, 1))
Case "a" To "z"
s1 = s1 + UCase(Mid(s, i, 1))
Case Else
s1 = s1 + Mid(s, i, 1)
End Select
Next i
Print s1
End Sub
- 2楼网友:渊鱼
- 2021-04-14 10:02
不难的!
Private Sub Command1_Click()
Dim i, n, t, p
n = Len(Text1.Text)
p = ""
For i = 1 To n
t = Mid(Text1.Text, i, 1)
If Asc(t) >= Asc("A") And Asc(t) <= Asc("Z") Then
p = p & Chr(Asc(t) + 32)
ElseIf Asc(t) >= Asc("a") And Asc(t) <= Asc("z") Then
p = p & Chr(Asc(t) - 32)
Else
p = p + t
End If
Next i
Text2.Text = p
End Sub
Private Sub Command1_Click()
Dim i, n, t, p
n = Len(Text1.Text)
p = ""
For i = 1 To n
t = Mid(Text1.Text, i, 1)
If Asc(t) >= Asc("A") And Asc(t) <= Asc("Z") Then
p = p & Chr(Asc(t) + 32)
ElseIf Asc(t) >= Asc("a") And Asc(t) <= Asc("z") Then
p = p & Chr(Asc(t) - 32)
Else
p = p + t
End If
Next i
Text2.Text = p
End Sub
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯