How can you change it so when an input pops up any character you type in such as for a Password is the same thing as in an * instead of the actual character.
I know this is rather stupid and simple but my programming book in school is a joke as I figured it would be but its an easy A if nothing else as well as teaches me the basics quite well.
Use the PasswordChar property:
MyTextBox.PasswordChar = "*"
I'm pretty sure he means for InputBox().
As far as I know, it's impossible to get a password character on an input box. Try searching MSDN (http://msdn.microsoft.com/) for more on this!
Yeah I did mean for InputBox()
I was searching though and came across.
void SetPasswordChar( TChar ch);
I'm hoping this works but I really can't test it until I get back to school tomorrow.
That function won't work; it's a member of the MFC CEdit class, not available to Visual Basic.
Searching through MSDN I did not find anything. However, I googled:
http://www.freevbcode.com/ShowCode.asp?ID=1214
I used the Google phrase:
password character input box visual basic
The response was the FIRST result returned. How well did you Google? :P
I looked for almost an hour using about 5 different phrases. :(
Normally I have better luck than that. I'm still trying to understand what that code does though because I'm still in the first half of VB in high school with a very crappy textbook.
Maybe you should just create your own modal form with password masking textboxes?
Quote from: Super on October 13, 2004, 12:53 AM
I looked for almost an hour using about 5 different phrases. :(
Normally I have better luck than that. I'm still trying to understand what that code does though because I'm still in the first half of VB in high school with a very crappy textbook.
Confused about what it does?
'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&, ByVal nIDEvent&, ByVal uElapse&, ByVal _
lpTimerFunc&)
Private Declare Function KillTimer& Lib "user32" _
(ByVal hwnd&, ByVal nIDEvent&)
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&
These statements simply declare API functions to communicate directly with the operating system.
[It also declares two constants for use in the 2nd argument of SendMessage and the 2nd argument in SetTimer, respectively.]
'PUT THIS SUB IN A .BAS MODULE
Public Sub TimerProc(ByVal hwnd&, ByVal uMsg&, _
ByVal idEvent&, ByVal dwTime&)
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
'THIS IS HOW TO USE THE CODE FROM WITHIN A FORM
Private Sub Command1_Click()
Dim ret As String
SetTimer hwnd, NV_INPUTBOX, 10, AddressOf TimerProc
ret = InputBox("Enter Password")
End Sub
This snippet creates a Sub that will send API messages to a given window.
i.e. The form created by InputBox()
At the end, it simply uses the pre-made Sub in a Click event.
Edit contained in []