Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Mask input in input boxes?

Is it possible to put an input mask on an input box? I'd like for the user to input a password and for the characters to come up as *'s. I think this would be possible if I made a form to do it, but it would be easier if I could do it for an input box

Thanks

Eric
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default Mask input in input boxes?

Eric,

It can't be done with an InputBox. You need to use a user from
with a text box whose PasswordChar property is set to '*'.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Eric" wrote in message
...
Is it possible to put an input mask on an input box? I'd like

for the user to input a password and for the characters to come
up as *'s. I think this would be possible if I made a form to do
it, but it would be easier if I could do it for an input box.

Thanks!

Eric



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Mask input in input boxes?

Okay. Thanks Chip!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 214
Default Mask input in input boxes?

Hi Eric;
Private Declare Function GetClassName& Lib "user32" Alias _
"GetClassNameA" (ByVal hWnd&, ByVal lpClassName$, ByVal nMaxCount&)
Private Declare Function GetWindowLong& Lib "user32" Alias _
"GetWindowLongA" (ByVal hWnd&, ByVal nIndex&)
Private Declare Function IsWindow& Lib "user32" (ByVal hWnd&)
Private Declare Function SetWindowsHookEx& Lib "user32" Alias _
"SetWindowsHookExA" (ByVal idHook&, ByVal lpfn&, ByVal hmod&, ByVal
dwThreadId&)
Private Declare Function SetWindowPos& Lib "user32" _
(ByVal hWnd&, ByVal hWndInsertAfter&, ByVal x&, ByVal y& _
, ByVal cx&, ByVal cy&, ByVal wFlags&)
Private Declare Function SetWindowLong& Lib "user32" _
Alias "SetWindowLongA" (ByVal hWnd&, ByVal nIndex&, ByVal dwNewLong&)
Private Declare Function UnhookWindowsHookEx& Lib "user32" (ByVal hHook&)
Private Declare Function GetCurrentThreadId Lib "KERNEL32" () As Long

Private Type CWPSTRUCT
lParam As Long
wParam As Long
Message As Long
hWnd As Long
End Type

Private MyHook&

Sub PasswordInput()
Dim Prompt As String
#If VBA6 Then
MyHook = SetWindowsHookEx(4, AddressOf InputWndProc, 0,
GetCurrentThreadId)
#Else
MyHook = SetWindowsHookEx(4, AddrOf("InputWndProc"), 0,
GetCurrentThreadId)
#End If
Prompt = InputBox("Enter your password !", "Masked input")
If Not Prompt = "" Then MsgBox "The password is: " & Prompt
End Sub

Private Function InputWndProc&(ByVal nCode&, ByVal wParam&, Struct As
CWPSTRUCT)
If Struct.Message < &H1 Then Exit Function
Dim hWnd&, oldStyle&, iClass As String
hWnd = Struct.hWnd
oldStyle = GetWindowLong(hWnd, -16)
iClass = GetWindowClass(hWnd)
If iClass = "edit" Then
oldStyle = oldStyle Or &H20&
SetWindowLong hWnd, -16, oldStyle
SetWindowPos hWnd, 0, 0, 0, 180, 20, &H2
UnhookWindowsHookEx MyHook
End If
End Function

Private Function GetWindowClass$(ByVal hWnd&)
Dim Buffer As String, iPos As Byte
If IsWindow(hWnd) Then
Buffer = String(255, 0)
Call GetClassName(hWnd, Buffer, 256)
iPos = InStr(Buffer, Chr(0))
Buffer = IIf(iPos, Left(Buffer, iPos - 1), Buffer)
GetWindowClass = LCase(Buffer)
End If
End Function

MP

"Eric" a écrit dans le message de
...
Is it possible to put an input mask on an input box? I'd like for the

user to input a password and for the characters to come up as *'s. I think
this would be possible if I made a form to do it, but it would be easier if
I could do it for an input box.

Thanks!

Eric



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 214
Default Mask input in input boxes?

For excel97, you must add:
Private Declare Function GetCurrentVbaProject Lib "vba332.dll" Alias _
"EbGetExecutingProj" (hProject As Long) As Long
Private Declare Function GetFuncID Lib "vba332.dll" Alias "TipGetFunctionId"
_
(ByVal hProject As Long, ByVal strFunctionName As String _
, ByRef strFunctionID As String) As Long
Private Declare Function GetAddr Lib "vba332.dll" Alias
"TipGetLpfnOfFunctionId" _
(ByVal hProject As Long, ByVal strFunctionID As String _
, ByRef lpfnAddressOf As Long) As Long

#If VBA6 Then
#Else
'* AddressOf operator replacement for Office97 VBA
'* Authors: Ken Getz and Michael Kaplan
Private Function AddrOf(CallbackFunctionName As String) As Long
Dim aResult As Long, CurrentVBProject As Long, strFunctionID As String
Dim AddressOfFunction As Long, UnicodeFunctionName As String

'* Convert the name of the function to Unicode system
UnicodeFunctionName = StrConv(CallbackFunctionName, vbUnicode)
'* If the current VBProjects exists...
If Not GetCurrentVbaProject(CurrentVBProject) = 0 Then
'* ...get the function ID of the callback function, based on its
'* unicode-converted name, in order to ensure that it exists
aResult = GetFuncID(hProject:=CurrentVBProject, _
strFunctionName:=UnicodeFunctionName, strFunctionID:=strFunctionID)
'* If the function exists indeed ...
If aResult = 0 Then
' *...get a pointer to the callback function based on
' * the strFunctionID argument of the GetFuncID function
aResult = GetAddr(hProject:=CurrentVBProject, _
strFunctionID:=strFunctionID, lpfnAddressOf:=AddressOfFunction)
'* If we've got the pointer pass it to the result of the function
If aResult = 0 Then AddrOf = AddressOfFunction
End If
End If
End Function
#End If

"Eric" a écrit dans le message de
...
Is it possible to put an input mask on an input box? I'd like for the

user to input a password and for the characters to come up as *'s. I think
this would be possible if I made a form to do it, but it would be easier if
I could do it for an input box.

Thanks!

Eric



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Time Input Mask brett Excel Discussion (Misc queries) 0 January 13th 08 08:43 PM
Input Mask Steven Excel Worksheet Functions 1 January 16th 06 11:27 PM
input mask in excel Osama Mira Excel Worksheet Functions 6 December 6th 05 10:00 PM
How do I add input data in the input ranges in drop down boxes. oil_driller Excel Discussion (Misc queries) 1 November 9th 05 10:31 PM
Input Mask Jimmy Clay New Users to Excel 3 December 1st 04 01:16 AM


All times are GMT +1. The time now is 02:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"