vb的题目,关于大小写转换的,大虾帮帮忙

2024-11-24 18:39:00
推荐回答(2个)
回答1:

建立两个文本框

Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim x As String * 1
x = Chr$(KeyAscii)
Select Case x
Case "A" To "Z"
x = Chr$(KeyAscii + 32)
Case "a" To "z"
x = Chr$(KeyAscii - 32)
Case Else
x = x
End Select
Text2.Text = Text2.Text & x
End Sub

回答2:

Private Sub Command1_Click()
Text1.Text = ""
Text2.Text = ""
Dim a, b, s
For i = 1 To Len(Text1.Text)
x = Mid(Text1.Text, i, 1)
a = Asc(x)
If a >= 65 And a <= 90 Then
b = Chr(a + 32)
End If
If a >= 87 And a <= 122 Then
b = Chr(a - 32)
End If
If a < 65 And a > 122 Then
b = x
End If
s = s & b
b = ""
Next i
Text2.Text = s
End Sub
不知道题目的意识``给两种
Private Sub Text1_KeyPress(KeyAscii As Integer)
Static s
Dim a, b
a = KeyAscii
If a >= 65 And a <= 90 Then
b = Chr(a + 32)
End If
If a >= 87 And a <= 122 Then
b = Chr(a - 32)
End If
If a < 65 And a > 122 Then
b = Chr(a)
End If
s = s & b
b = " "
Text2.Text = s
End Sub