Sunday, 18 August 2013

How to accept masked characters in an user created input box

How to accept masked characters in an user created input box?
Problem Description – When we 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.
It can’t be handled either by using the built-in InputBox function or by using Crypt method.
Code to solve this problem is as follows –
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.

No comments:

Post a Comment