cancel
Showing results for 
Search instead for 
Did you mean: 

Implement my own password field

AdKerremans
Active Contributor
0 Kudos

I have implemented my own "password" field.

I catch the before_action of the et_KEY_DOWN event, check for the delete and backspace, displays an '*' or clears the field and bubbleevent is false.

my code is below.

If pVal.CharPressed = 8 Or pVal.CharPressed = 46 Then

pincode = ""

oApp.Forms.Item(FormUID).Items.Item "pincode").Specific.string = ""

Else

oApp.Forms.Item(FormUID).Items.Item"pincode").Specific.string += "*"

pincode += Chr(pVal.CharPressed)

End If

BubbleEvents = False

My problem is that the cursor stays at the beginning of my field.

How can I move it to the end of this field.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

how about uiing sendkeys function to mimick the End key press

AdKerremans
Active Contributor
0 Kudos

Sorry, but this solution does not work.

I am in the before_action and sending another event, this causes a loop in the events and my add-on crashes.

AdKerremans
Active Contributor
0 Kudos

I was to quick in answering.

I added

If pVal.CharPressed = 35 Then Return

at the start of my code and it works

Answers (4)

Answers (4)

Former Member
0 Kudos

anyway, how do you handle such features, as a:

input of character in the middle of password ???

for example:

I want to type in my password "asdf" and I've made a typo and I'm sure, that I've forgot to type the "s", so in the password field, I have the "***"-"adf" thus, I move right after the first char and press the "s" (or copy/paste the string containing the "s" or whatever) ... what happends ? you add the "s" at the end of your pincode ... and ups, you have the "adfs" instead of "asdf" ...

and more problems appear ... when:

user marks (using mouse, or shift+movement_arrows) more chars, and inputs the desired char/string ...

This was the reason ... why I'm using a linkedbutton, which opens new form, with empty editbox, to type in the password ... fully visible, ofcourse ...

Former Member
0 Kudos

But you still can't use copy/paste to input your password, right? Anybody else have better idea?

Former Member
0 Kudos

why copy/paste your password. this is not a recommended tactic. Who wants to copy/paste password anyway?

However you can do this putting the above piece of code under "Private Sub text1_KeyDown(KeyCode As Integer, Shift As Integer)" within an IFBLock to check ctrlV and/or CtrlC.

On the above code you should also for keys like BackSpace(ascii 😎

Message was edited by: Spiros Koutoulas

Former Member
0 Kudos

This piece of code how how i have implemented what you want in visual basic.

Dim pswd As String

Private Sub Text1_KeyPress(KeyAscii As Integer)

pswd = pswd + Chr(KeyAscii)

KeyAscii = Asc("*")

End Sub

'You can change "*" to anything.

barend_morkel2
Active Contributor
0 Kudos

Don't set "BubbleEvents = False" - you do want the action to complete

AdKerremans
Active Contributor
0 Kudos

I do not want the action to complete, because I do not want to see the character typed

barend_morkel2
Active Contributor
0 Kudos

So you're stuck between a rock and a hard place. Would it work if you cut the entire line of the password and paste it after each character is typed?