InputBox with Password Characters(转帖)
The following codes are from http://www.freevbcode.com/ShowCode.asp?ID=1214
'Add a form with commandbutton:
Private Sub Command1_Click()
Dim ret As String
SetTimer hwnd, NV_INPUTBOX, 10, AddressOf TimerProc
ret = InputBox("Enter Password")
MsgBox ret
End Sub
'Add a standard modual:
'PUT BELOW DECLARATIONS IN A .BAS MODULE
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias _
"FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, _
ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Public Declare Function SetTimer Lib "user32" _
(ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal _
lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib "user32" _
(ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long
Const EM_SETPASSWORDCHAR = &HCC
Public Const NV_INPUTBOX As Long = &H5000&
Public Sub TimerProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal idEvent As Long, ByVal dwTime As Long)
Dim EditHwnd As Long
' CHANGE APP.TITLE TO YOUR INPUT BOX TITLE.
EditHwnd = FindWindowEx(FindWindow("#32770", App.Title), _
0, "Edit", "")
Call SendMessage(EditHwnd, EM_SETPASSWORDCHAR, Asc("*"), 0)
KillTimer hwnd, idEvent
End Sub