VB在文本框中输入一个字符串,将其中的小写字符转换为大写字符,大写字符转换为小写字符,

如题所述

第1个回答  2013-02-20
若文本框是text1,则
text1.text = LCase(text1.text)
或简写
text1 = LCase(text1)
第2个回答  2013-02-20
a = LCase("This Is A String") ' a 的值为 "this is a string"a = UCase("This Is A String") ' a 的值为 "THIS IS A STRING"
第3个回答  推荐于2018-02-28
转换小写为大写:LCase函数,例如XX = LCase("abcd"),返回值:XX = "ABCD"
转换大写为小写:UCase函数,例如XX = UCase("ABCD"),返回值:XX = "abcd"
可以:XX = LCase(Text1.Text) 或 XX = UCase(Text1.Text),全部转换为大写或小写;如果 Text1.Text 中的大写转换为小写,小写转换为大写,需要逐字符检测并转换。

代码如下:
Private Sub Command1_Click()
Dim XX As String, YY As String, ZZ As String, AA As Integer, I As Integer
XX = Text1.Text
AA = Len(XX)
For I = 1 To AA
ZZ = Mid(XX, I, 1)
If Asc(ZZ) >= 65 And Asc(ZZ) <= 90 Then
ZZ = LCase(ZZ)
ElseIf Asc(ZZ) >= 97 And Asc(ZZ) <= 122 Then
ZZ = UCase(ZZ)
End If
YY = YY & ZZ
Next I
Text1.Text = YY
End Sub本回答被网友采纳
第4个回答  2013-02-20
百度不是廉价的回答!!有作用吗?
第5个回答  2013-02-20
那个都行。
相似回答