Excel VBA Input box

前端 未结 5 1498
说谎
说谎 2020-12-06 06:52

I have following Input box for excel file. I don\'t want to show typing characters and need to show input box characters * , how to do this?

Private Sub Wor         


        
5条回答
  •  有刺的猬
    2020-12-06 07:42

    Use a UserForm Create a userform that has a Textbox, and Two Buttons In the textbox Properties, enter * in the PasswordChar Box

    enter image description here

    Use the code below in the userForm module.

    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
    

    Your userform will look like this

    enter image description here

提交回复
热议问题