【求解】VB 同时转换字符串中字母的大小写 怎么写程序
是要字符串中大写换成小写,小写换成大写,不是都换成大写或小写。Ucase和Lcase是把字符串通通转换成大写或小写。试过用Mid(s,p,n),不过写不出。求解求解。...
是要字符串中大写换成小写,小写换成大写,不是都换成大写或小写。
Ucase 和 Lcase是把字符串通通转换成大写或小写。
试过用Mid(s,p,n),不过写不出。求解求解。 展开
Ucase 和 Lcase是把字符串通通转换成大写或小写。
试过用Mid(s,p,n),不过写不出。求解求解。 展开
3个回答
2012-12-17
展开全部
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
展开全部
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
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
不难的!
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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询