我有一个文本框(PinEntry)和一个复选框。选中时,复选框将屏蔽密码。然而,它只屏蔽一次。我理解第一个子例程的逻辑,即只要我还在文本框中输入值,它就应该屏蔽条目。
Private Sub CheckBox1_Click()
If AccessForm.PinEntry.Value = True Then
AccessForm.PinEntry.PasswordChar = ""
ElseIf AccessForm.PinEntry.Value = False Then
AccessForm.PinEntry.PasswordChar = "*"
Else
AccessForm.PinEntry.PasswordChar = "*"
End If
End Sub
Private Sub PinEntry_Change()
CheckBox1_Click
End Sub发布于 2021-06-11 11:32:04
您的代码仅在单击时才会屏蔽的原因是因为您将只输入最后的Else语句。您正在检查PinEntry (Textbox)是否具有布尔值True或False,但永远不会。
当PinEntry中的文本发生更改时,无需调用checkbox click事件。Passwordchar是一个仅当您想要启用或禁用它时才需要在textbox上设置的属性。您只需在单击复选框时执行操作。
如果复选框被选中,此代码将显示pin,如果未选中,则应用掩码。
Private Sub CheckBox1_Click()
If CheckBox1.Value Then
PinEntry.PasswordChar = ""
Else
PinEntry.PasswordChar = "*"
End If
End Subhttps://stackoverflow.com/questions/67929954
复制相似问题