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

  1. Set MyForm = DotNetFactory.CreateInstance("System.Windows.Forms.Form", "System.Windows.Forms")
  2.  
  3. Set MyText = DotNetFactory.CreateInstance("System.Windows.Forms.TextBox", "System.Windows.Forms")
  4.  
  5. Set MyButton = DotNetFactory.CreateInstance("System.Windows.Forms.Button", "System.Windows.Forms")
  6.  
  7. Set Pos = DotNetFactory.CreateInstance("System.Drawing.Point"
  8. ,"System.Drawing",x,y)
  9.  
  10. Pos.X = 90
  11. Pos.Y = 100
  12. MyText.Location = Pos
  13. MyText.Width = 100
  14. MyText.UseSystemPasswordChar = true
  15. Pos.X = 100
  16. Pos.Y = 130
  17. MyButton.Location = Pos
  18. MyButton.Text = "Close"
  19. MyForm.Controls.Add MyText
  20. MyForm.Controls.Add MyButton
  21. MyForm.CancelButton = MyButton
  22. MyForm.ShowDialog
  23.  
  24. Msgbox MyText.Text
  25.  
  26. Set MyText = Nothing
  27. Set MyButton = Nothing
  28. Set Pos = Nothing
  29. 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.