Thursday, December 31, 2009

Masking Password Using DotNet Factory

If you want to mask your password instead of placing in datatable or encrypting it, then use the below code.

Set oForm=DotNetFactory.CreateInstance("System.Windows.Forms.Form","System.Windows.Forms")
Set oTextBox=DotNetFactory.CreateInstance("System.Windows.Forms.TextBox","System.Windows.Forms")Set oButton = DotNetFactory.CreateInstance("System.Windows.Forms.Button", "System.Windows.Forms")
Set oPoint = DotNetFactory.CreateInstance("System.Drawing.Point", "System.Drawing", x, y)

With oPoint
.x = 120
.y = 20
End With

With oButton
.Location = oPoint
.Width = 100
.Text = "OK"
End with

With oPoint

.x = 0
.y = 20
End With

With oTextBox

.Location = oPoint
.UseSystemPasswordChar=True
End with

'Add Controls

With oForm
.CancelButton = oButton
.Controls.Add oButton
.Controls.Add oTextBox
End with

oForm.ShowDialog
Msgbox oTextBox.Text



Set oForm=Nothing
Set oTextBox=Nothing
Set oButton=Nothing
Set oPoint=Nothing
Run the above code you will get a DOT Net dialog like below.


Enter your password and click on OK button. The entered password will be displayed in a message box.
For more information about DOT Net controls, please refer the below link.

8 comments: