vb里获得焦点的文本框背景颜色改为红色 如何用if语句编写
2个回答
展开全部
假设3个文本框:
Private Sub Text1_GotFocus()
Text1.BackColor = vbRed
Text2.BackColor = vbWhite
Text3.BackColor = vbWhite
End Sub
Private Sub Text2_GotFocus()
Text1.BackColor = vbWhite
Text2.BackColor = vbRed
Text3.BackColor = vbWhite
End Sub
Private Sub Text3_GotFocus()
Text1.BackColor = vbWhite
Text2.BackColor = vbWhite
Text3.BackColor = vbRed
End Sub
追问
你看一下我上面那个追问吧 我这边不行的 是要点击按钮才可以做到
追答
Dim TextFocus As Integer
Private Sub Command1_Click()
Text1.SetFocus
End Sub
Private Sub Command2_Click()
Text2.SetFocus
End Sub
Private Sub Command3_Click()
If TextFocus = 1 Then
Text1.BackColor = vbRed
Text2.BackColor = vbWhite
Else
Text1.BackColor = vbWhite
Text2.BackColor = vbRed
End If
End Sub
Private Sub Text1_GotFocus()
TextFocus = 1
End Sub
Private Sub Text2_GotFocus()
TextFocus = 2
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询