21. dubna 2006 15:29
Hello all first time post on this forum been using VBA for some time and i got so much help there i figure it's worth a go :).
i have been asked to make a form password entry but cant use a text box as it's opened from an MDI parent form so no main screen to speak of as such, my problem is at current the password works fine as shown below its basic stuff.
IfInputBox("Please Enter Administration Password." _
,"Password Entry", "") = "trafficlight" Then 'Close current frmMDIChild and set the new form
frmMDIChild =New frmAdmin 'Set the Parent Form of the Child window.
frmMDIChild.MdiParent =Me 'Display the new form.
MsgBox("Password was incorrect please try again.", MsgBoxStyle.OkOnly, "ERROR") End If
but i'm pretty new to VB.Net and want the input box to mask the characters been entered i know i could create my own input box and call that but is there a way to use the Default inputbox to mask the character input maybe watch the key presses saving input to a variable and displaying the asterix in its place? or am i overthinking it and there is a very easy solution like an inputbox that already masks input by a user.
thanks for reading hope some one can help me :).
21. dubna 2006 17:24
I'm not quite sure why you have to use an Inputbox to get a password and cannot use a specific Login Form.
VB.net provides a template for a login form and all your going to have to do is a little bit of coding to make it all happen.
An article on this is as follows.
So In the Login Form You can code something like
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
If Me.UsernameTextBox.Text = "ADMIN" And Me.PasswordTextBox.Text = "trafficlight" Then
Me.DialogResult = System.Windows.Forms.DialogResult.OK
MsgBox("Password was incorrect please try again.", MsgBoxStyle.OkOnly, "ERROR")
Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
And in the main form that you are calling this from you'll have code something like this which will only do the action you want when the LoginForm returns OK
'Display the login dialog.
Dim dlg As New LoginForm1
If dlg.ShowDialog = Windows.Forms.DialogResult.OK Then
'Close current frmMDIChild and set the new form
frmMDIChild = New frmAdmin
'Set the Parent Form of the Child window.
frmMDIChild.MdiParent = Me
'Display the new form.
This way you password is not being shown and you can design the form to whatever you want - the fact that your calling from an MDI Main form shouldnt make a difference.
21. dubna 2006 19:37
I've just coded up a login feature for some software I'm rewriting and the input box doesn't let you specify a password character. You shouldn't really use it anyway as you'd be storing the password in memory as a readable string. With a custom login (there's a template login form in VS2005) you get the asterix and you can read the password into a SecureString or even just use the hashcode (string.GetHashCode). You have more control over the password with a custom login screen and thats what you want.
24. dubna 2006 10:12
Thanks Guys i'll look into that thought there was no way of using the input box that way i'm just doing as i'm asked i'll show them the Login page and see what happens its the down side of been a student my comments are not as valid and my lack of confidence leads me to attempting things i suspect are not posible based on my lack of knowledge of a specific language.
thanks again all for your help :) appreciated as always :) hope one day to contribute back to this forum rather than been the new comer lost in a sea of information :).
4. dubna 2012 15:07hey man, this is my solution, in actuality i used .net 2005, and the conversion the vb 6 to .net 2005 is not very simple, i used one frame with textbox, and the code of textbox you write your before code