帮我编写一个程序吧!很急!!!
编写一个大小写字母自动转换程序,当输入小写字母时,自动转换成大写字母,当输入大写字母时,自动转换为小写字母,当输入其他字符时,转换显示为“*”...
编写一个大小写字母自动转换程序,当输入小写字母时,自动转换成大写字母,当输入大写字母时,自动转换为小写字母,当输入其他字符时,转换显示为“*”
展开
展开全部
form中放置一个按钮和2个textbox,运行时在text1输入信息,点击按钮后在text2看到输出结果。
Private Sub Command1_Click()
Dim s
For i = 1 To Len(Text1)
n = Asc(Mid(Text1, i, 1))
If n >= Asc("a") And n <= Asc("z") Then s = s & Chr(n - 32) Else _
If n >= Asc("A") And n <= Asc("Z") Then s = s & Chr(n + 32) Else s = s & "*"
Next
Text2 = s
End Sub
Private Sub Command1_Click()
Dim s
For i = 1 To Len(Text1)
n = Asc(Mid(Text1, i, 1))
If n >= Asc("a") And n <= Asc("z") Then s = s & Chr(n - 32) Else _
If n >= Asc("A") And n <= Asc("Z") Then s = s & Chr(n + 32) Else s = s & "*"
Next
Text2 = s
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
只需要添加一个TEXTBOX
然后直接在里面输入就可以看到效果
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii >= 97 And KeyAscii <= 122 Then
KeyAscii = KeyAscii - 32
Else
If KeyAscii >= 65 And KeyAscii <= 90 Then
KeyAscii = KeyAscii + 32
Else
KeyAscii = 42
End If
End If
End Sub
然后直接在里面输入就可以看到效果
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii >= 97 And KeyAscii <= 122 Then
KeyAscii = KeyAscii - 32
Else
If KeyAscii >= 65 And KeyAscii <= 90 Then
KeyAscii = KeyAscii + 32
Else
KeyAscii = 42
End If
End If
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Form_Load()
MsgBox "aBcDeFG159HIJkl5mnOPQRS" & vbCrLf & Rstr("aBcDeFG159HIJkl5mnOPQRS")
End Sub
'通用函数
Private Function Rstr(ByVal sstr As String) As String
Dim TempStr As String
For i = 1 To Len(sstr)
If Asc(Mid(sstr, i, 1)) >= Asc("a") And Asc(Mid(sstr, i, 1)) <= Asc("z") Then
TempStr = TempStr & Chr(Asc(Mid(sstr, i, 1)) - 32)
Else
If Asc(Mid(sstr, i, 1)) >= Asc("A") And Asc(Mid(sstr, i, 1)) <= Asc("Z") Then
TempStr = TempStr & Chr(Asc(Mid(sstr, i, 1)) + 32)
Else
TempStr = TempStr & "*"
End If
End If
Next i
Rstr = TempStr
End Function
MsgBox "aBcDeFG159HIJkl5mnOPQRS" & vbCrLf & Rstr("aBcDeFG159HIJkl5mnOPQRS")
End Sub
'通用函数
Private Function Rstr(ByVal sstr As String) As String
Dim TempStr As String
For i = 1 To Len(sstr)
If Asc(Mid(sstr, i, 1)) >= Asc("a") And Asc(Mid(sstr, i, 1)) <= Asc("z") Then
TempStr = TempStr & Chr(Asc(Mid(sstr, i, 1)) - 32)
Else
If Asc(Mid(sstr, i, 1)) >= Asc("A") And Asc(Mid(sstr, i, 1)) <= Asc("Z") Then
TempStr = TempStr & Chr(Asc(Mid(sstr, i, 1)) + 32)
Else
TempStr = TempStr & "*"
End If
End If
Next i
Rstr = TempStr
End Function
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
试试我的!
窗体上添加一Text控件,并在它的KeyPress事件下写入如下代码:
Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 97 To 122: KeyAscii = KeyAscii - 32 'lowercase to CAPITAL
Case 65 To 90: KeyAscii = KeyAscii + 32 'CAPITAL TO lowercase
Case Else: KeyAscii = Asc("*") 'Else all out "*"
End Select
End Sub
窗体上添加一Text控件,并在它的KeyPress事件下写入如下代码:
Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 97 To 122: KeyAscii = KeyAscii - 32 'lowercase to CAPITAL
Case 65 To 90: KeyAscii = KeyAscii + 32 'CAPITAL TO lowercase
Case Else: KeyAscii = Asc("*") 'Else all out "*"
End Select
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
加一text框
Dim M, I, N As String
Private Sub Text1_KeyPress(KeyAscii As Integer)
M = CStr(KeyAscii)
If M >= 65 And M <= 90 Then
M = M + 32
N = ChrW(M)
Print N;
Else
If M >= 97 And M <= 122 Then
M = M - 32
N = ChrW(M)
Print N;
Else
Print "*";
End If
End If
End Sub
(不明白,或不行来找我。QQ839777383)
Dim M, I, N As String
Private Sub Text1_KeyPress(KeyAscii As Integer)
M = CStr(KeyAscii)
If M >= 65 And M <= 90 Then
M = M + 32
N = ChrW(M)
Print N;
Else
If M >= 97 And M <= 122 Then
M = M - 32
N = ChrW(M)
Print N;
Else
Print "*";
End If
End If
End Sub
(不明白,或不行来找我。QQ839777383)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询