vb 大小写转换 在text1输入大写字母,在text2中显示小写,在text1中输入大写,在text2中小写,其余不变 10
PrivateSubText1_KeyPress(KeyAsciiAsInteger)DimxAsStringx=KeyAsciiSelectCasexCase65To9...
Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim x As String
x = KeyAscii
Select Case x
Case 65 To 90
x = KeyAscii + 32
Case 97 To 122
x = KeyAscii - 32
Case 8
x = ""
Case Else
x = x
End Select
Text2.Text = Text2.Text & Chr$(x)
End Sub
这是我的代码,可是哪位大神告诉我退格键怎么设啊,text1退格怎么让text2也退格呢 展开
Dim x As String
x = KeyAscii
Select Case x
Case 65 To 90
x = KeyAscii + 32
Case 97 To 122
x = KeyAscii - 32
Case 8
x = ""
Case Else
x = x
End Select
Text2.Text = Text2.Text & Chr$(x)
End Sub
这是我的代码,可是哪位大神告诉我退格键怎么设啊,text1退格怎么让text2也退格呢 展开
3个回答
展开全部
'把你的代码删除,改成这样不更好吗!在change事件里不要在KeyPress
Private Sub Text1_Change()
Text2.Text = LCase(Text1.Text)
End Sub
Private Sub Text1_Change()
Text2.Text = LCase(Text1.Text)
End Sub
追问
这样把小写改为大写了,可是不能把大写改为小写呢
追答
'添加代码,则自动改变大小写到文本1 和 2
Private Sub Text2_Change()
Text1.Text = UCase(Text2.Text)
End Sub
Private Sub Text1_Change()
Text2.Text = LCase(Text1.Text)
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你把Text1,Text2的"MultiLine"属性改为True就可以了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
楼上的代码也可以
第一种:
Private Sub Text1_Change()
Text2 = UCase(Text1)
End Sub
第二种:你的
Private Sub Form_Load()
Text1 = ""
Text2 = ""
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 65 To 90
KeyAscii = KeyAscii + 32
Case 97 To 122
KeyAscii = KeyAscii - 32
Case 8
If Len(Text2) = 0 Then Exit Sub
Text2 = Left(Text2, Len(Text2) - 1)
Exit Sub
End Select
Text2.Text = Text2 & Chr(KeyAscii)
End Sub
第一种:
Private Sub Text1_Change()
Text2 = UCase(Text1)
End Sub
第二种:你的
Private Sub Form_Load()
Text1 = ""
Text2 = ""
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 65 To 90
KeyAscii = KeyAscii + 32
Case 97 To 122
KeyAscii = KeyAscii - 32
Case 8
If Len(Text2) = 0 Then Exit Sub
Text2 = Left(Text2, Len(Text2) - 1)
Exit Sub
End Select
Text2.Text = Text2 & Chr(KeyAscii)
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询