基本上,我创建了一个用户表单,我想知道是否可以添加灰色文本。当用户开始输入文本时,该文本会消失:
[图像已过期]
一旦用户开始输入,字体颜色应更改为黑色。
任何帮助都将不胜感激。
这样子就可以了吗?
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
屏幕截图(演示)