PassWordChar Property

Purpose

Returns or sets a character to be used as a password character.

Syntax

object.PassWordChar [ = chr$ ]

object:Textbox, RichEdit Ocx
chr$:sexp

Description

Displays all characters as an asterisk (*) as they are typed into the edit control. An application can use the PassWordChar property to change the character that is displayed.

Setting PassWordChar = "" disables the password mode.

Example

Global tpos As Int32

Text 10, 10, "Password: "

Ocx TextBox tb = "", 65, 10, 100, 14 : tb.BorderStyle = 1 : tb.PassWordChar = "*"

Ocx Command cmd = "Show", 170, 8, 60, 20

Ocx CheckBox chk = "Use '#' character instead of ' * '", 10, 40, 175, 14

tb.SetFocus

Do : Sleep : Until Me Is Nothing

 

Sub chk_Click

Select chk.Value

Case 0 : tb.PassWordChar = "*"

Case 1 : tb.PassWordChar = "#"

EndSelect

tb.SetFocus

EndSub

 

Sub cmd_MouseDown(Button&, Shift&, x!, y!)

tb.PassWordChar = ""

EndSub

 

Sub cmd_MouseUp(Button&, Shift&, x!, y!)

chk_Click

EndSub

 

Sub tb_GotFocus

tb.SelStart = tpos

EndSub

 

Sub tb_LostFocus

If Not tb Is Nothing Then tpos = tb.SelStart

EndSub

Known Issues

tb.PassWordChar works like tb.PassWordChar="" rather than tb.PassWordChar="*" as it should.

See Also

TextBox, RichEdit

{Created by Sjouke Hamstra; Last updated: 21/10/2014 by James Gaite}