One of the LearnQTP readers asked this question:
Hi Ankur,
I need help with Input Box .
When I enter password in Inputox( Wpass = InputBox(”EnterPassword”)) its showing up the “password” instead of “********” ..we need to prompt input box for a password and we need to hide a password while it is being typed.Do you have solution for this ? I googled it I came up with VBScript..Is it possible with InputBox Function..
Now, as far as I know this can’t be handled either by using the built-in InputBox function or by using Crypt method.
For those who still wonder about the applicability of DotNetFactory, you can use it here.
Using Example-11 from one of our earlier posts on DotNetFactory, you can modify it and add UseSystemPasswordChar method to make sure the entered characters are masked. This is what the modified code would look like
Set MyForm = DotNetFactory.CreateInstance("System.Windows.Forms.Form", "System.Windows.Forms")
Set MyText = DotNetFactory.CreateInstance("System.Windows.Forms.TextBox", "System.Windows.Forms")
Set MyButton = DotNetFactory.CreateInstance("System.Windows.Forms.Button", "System.Windows.Forms")
Set Pos = DotNetFactory.CreateInstance("System.Drawing.Point"
,"System.Drawing",x,y)
Pos.X = 90
Pos.Y = 100
MyText.Location = Pos
MyText.Width = 100
MyText.UseSystemPasswordChar = true
Pos.X = 100
Pos.Y = 130
MyButton.Location = Pos
MyButton.Text = "Close"
MyForm.Controls.Add MyText
MyForm.Controls.Add MyButton
MyForm.CancelButton = MyButton
MyForm.ShowDialog
Msgbox MyText.Text
Set MyText = Nothing
Set MyButton = Nothing
Set Pos = Nothing
Set MyForm = Nothing
True property under MyText.UseSystemPasswordChar = true will make sure that the entered characters are masked and are not visible to the user.
Run the above piece of code and let me know if this worked for you.
If you want to keep track of further articles on QTP. I recommend you to subscribe via RSS feed. You can also subscribe by Email and have new QTP articles sent directly to your inbox.
Related posts:



4 comments ↓
In Vb script we use SetSecure to appear the password in ******* form.
Kindly check if there is any method for dot net available!
It was not working . While, running script QTP can’t recognized Object.Input ask for Type for password and after putting letter in Input box, it’s want not encrypted.
Please let me know the solution and correct script.
Don’t worry he will be fine. All our good wishes are with him.
Hi Ankur,
I am looking for a concept “Broken Link” using descriptive programming” and how to test this for all the links .
Can you post the snippet for the following.
Thanxs in advance..
Leave a Comment