Excel VBAinput框

我有以下input框为Excel文件。 我不想显示input字符,需要显示input框字符*,如何做到这一点?

Private Sub Workbook_Open() Dim UserName As String UserName = InputBox("Please Enter Your USER NAME.") Range("O1") = UCase(UserName) End Sub 

谢谢,Hewage

使用用户窗体创build具有文本框和两个button的用户窗体在文本框属性中,在密码框中input*

在这里输入图像描述

在userForm模块中使用下面的代码。

 Private Sub CommandButton1_Click() If TextBox1 = "123456" Then MsgBox "Correct" Else MsgBox "Incorrect" End If Unload Me End Sub Private Sub CommandButton2_Click() 'cancel button Unload Me End Sub Private Sub UserForm_Initialize() Me.Caption = "Enter Password" End Sub 

您的用户表单将如下所示

在这里输入图像描述

ImputBox不支持屏蔽,所以你不能隐藏字符。 你需要使用一些像白色字符的文本框或类似的东西。