基本上,我已经创建了一个用户窗体,我想知道是否可以添加在加载用户窗体时存在的灰色文本,但是一旦用户开始向TextBox中输入文本,该文本就会消失:
Userform http://im34.gulfup.com/rDwF8.png
一旦用户开始输入字体颜色,应更改为黑色。
任何帮助将不胜感激。
Private Sub UserForm_Initialize()
TextBox1.ForeColor = &HC0C0C0 '<~~ Grey Color
TextBox1.Text = "Please Enter Name Here"
CommandButton1.SetFocus '<~~ This is required so that the focus moves from TB
End Sub
Private Sub TextBox1_Enter()
With TextBox1
If .Text = "Please Enter Name Here" Then
.ForeColor = &H80000008 '<~~ Black Color
.Text = ""
End If
End With
End Sub
Private Sub TextBox1_AfterUpdate()
With TextBox1
If .Text = "" Then
.ForeColor = &HC0C0C0
.Text = "Please Enter Name Here"
End If
End With
End Sub
ScreenShot(正在执行)