display *** in password label

Chandler_90
06-02-2005, 03:02 PM
Make your own thread - you are a different user
I also need something like this.. except my password is entered into an Inputbox.

I've tried to adapt some of the code but its too advanced for me. :o
What I have got is -

-----------------------------------------------------------------

Private Sub mnuExit_Click()
Dim Password As String
Dim InputPassword As String
Dim Attempt As Integer
Password = "secret"
Attempt = 0
Do
Attempt = Attempt + 1
InputPassword = InputBox("Enter Password. This is attempt " & "number " & Attempt)
Loop Until (Attempt = 3) Or (InputPassword = Password) 'this will end the loop
If InputPassword = Password Then
MsgBox ("The Program will now exit")
Unload Me
Else
MsgBox ("You do not have the priviliges required to complete this operation.")
End If

End Sub

-----------------------------------------------------------------

This allows the user to enter the password. How would I implement the stars or bulletpoints?

Thanks!

Iceplug
06-02-2005, 04:38 PM
Have a look at this thread.
http://www.xtremevbtalk.com/showthread.php?t=6010
You have to use a timer to monitor the inputbox and use APIs to Find the InputBox and change the character display to show *s. :)
Quite complex. You can also make your own password form to do this.

Chandler_90
06-02-2005, 05:47 PM
Thanks for helping me out.. I really appreciate this!

I've created a new form called frmPassword.
On mnuExit in my mdiMain it loads frmPassword as shown below -

-----------------------------------------------------------------

Private Sub mnuExit_Click()
load frmPassword
End Sub

-----------------------------------------------------------------

This then loads frmPassword which contains -

-----------------------------------------------------------------

Private Sub Form_Load()
Dim lTemp As Long
Dim sTemp As String
Dim Password As String
Password = "secret"
lTemp = SetTimer(Me.hwnd, NV_INPUTBOX, 1, AddressOf TimerProc)

sTemp = InputBox("Please Enter your password", "Security Dialogue")

If sTemp = Password Then
MsgBox ("The Program will now exit")
Unload frmPassword
Unload mdiMain

Else
MsgBox ("You do not have the priviliges required to complete this operation.")
End If

End Sub

-----------------------------------------------------------------

However everything unloads correctly (with *s for the password ) but right at the last minute I get this -

-----------------------------------------------------------------

Run-time error "364":

Object was unloaded

-----------------------------------------------------------------

Upon pressing debug it then Highlights the following in the mdiMain -

-----------------------------------------------------------------

Private Sub mnuExit_Click()
frmPassword.Visible = True <----------------------------This is Highlighted
End Sub

-----------------------------------------------------------------


As far as I can see I have unloaded it.. am I missing something?
Thanks.. :)

reboot
06-02-2005, 05:49 PM
That's right, it's unloaded, how can you set properties on it?

Chandler_90
06-02-2005, 05:55 PM
I don't know.. Think I might host the file so u can check it out.
I've only been doin this for 2 weeks. I'm gettin confused and its pretty late over here.
Its the last thing I need to sort out before I hand it in.. I just can't leave the thing alone!

reboot
06-02-2005, 05:56 PM
If you unload the form it's gone, why would you then try to set Visible = True? It's not there anymore.

Chandler_90
06-02-2005, 06:00 PM
It was just something I was messing about with and forgot to edit it out before posting.
Even with just -

Private Sub mnuExit_Click()
load frmPassword
End Sub

It still hightlights the middle section..
I don't understand. If I unload a form then, as you said, its gone.
But somehow the program thinks its still open :confused:

Cerian Knight
06-02-2005, 06:05 PM
Do not unload a form from its own Load event, let the calling form or module unload it. The problem might dissappear if you use a module instead of a form in place of frmPassword, then no unload is required because there is no form. Depends on what else is on the form.

Chandler_90
06-02-2005, 06:08 PM
So if I tansfer the contents of frmPassword into a module (all of frmpassword was posted above) I then won't need to unload anything..

I'll give it a shot..
Would I just call upon the module as if it was a function (Again I have been doing this for only 2 weeks so please forgive my stupid questions.)

Chandler_90
06-02-2005, 06:13 PM
Ok I've sorted it now.. It was a beginners error.
I had frmPassword set as a child of the mdiMain
Therefore when I tried to exit the mdiMain it crashed due to that form not closing in time.

Thank you for your helps guys.. I really appreciate it!
Without it I woulda failed this unit!

Thanks!!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum