如何在VB中inputbox密码显示为"*"呢?
4个回答
展开全部
先设置一个加密的算法,然后调用:
Private Function HookProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If nCode = HCBT_ACTIVATE Then
Dim hwndEdit As Long
hwndEdit = GetDlgItem(wParam, &H1324)
SetWindowLong hwndEdit, GWL_STYLE, ES_PASSWORD Or GetWindowLong(hwndEdit, GWL_STYLE)
SendDlgItemMessage wParam, &H1324, EM_SETPASSWORDCHAR, Asc("*"), 0
UnhookWindowsHookEx hHook
End If
HookProc = 0
End Function
Public Function InputMyBox(Prompt As String, Optional Title As String, Optional Default As String) As String
If Len(Title) = 0 Then Title = App.Title
hHook = SetWindowsHookEx(WH_CBT, AddressOf HookProc, App.hInstance, App.ThreadID)
InputMyBox = InputBox(Prompt, Title, Default)
End Function
使用时,编码如下:
Private Function Check_Sn() As String
Dim InputStr As String
InputStr = InputMyBox("你要输出的内容", "box名称")
End Function
Private Function HookProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If nCode = HCBT_ACTIVATE Then
Dim hwndEdit As Long
hwndEdit = GetDlgItem(wParam, &H1324)
SetWindowLong hwndEdit, GWL_STYLE, ES_PASSWORD Or GetWindowLong(hwndEdit, GWL_STYLE)
SendDlgItemMessage wParam, &H1324, EM_SETPASSWORDCHAR, Asc("*"), 0
UnhookWindowsHookEx hHook
End If
HookProc = 0
End Function
Public Function InputMyBox(Prompt As String, Optional Title As String, Optional Default As String) As String
If Len(Title) = 0 Then Title = App.Title
hHook = SetWindowsHookEx(WH_CBT, AddressOf HookProc, App.hInstance, App.ThreadID)
InputMyBox = InputBox(Prompt, Title, Default)
End Function
使用时,编码如下:
Private Function Check_Sn() As String
Dim InputStr As String
InputStr = InputMyBox("你要输出的内容", "box名称")
End Function
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
VB中inputbox不能以密码显示~~!!!!!
如果要实现你说的功能,那你自己做一个窗体就可以了~~~
如果要实现你说的功能,那你自己做一个窗体就可以了~~~
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询