Author | Message | Time |
---|---|---|
Super | 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. | October 13, 2004, 3:00 AM |
Stealth | Use the PasswordChar property: [code] MyTextBox.PasswordChar = "*" [/code] | October 13, 2004, 3:17 AM |
Newby | 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 for more on this! | October 13, 2004, 3:19 AM |
Super | Yeah I did mean for InputBox() I was searching though and came across. [code] void SetPasswordChar( TChar ch); [/code] I'm hoping this works but I really can't test it until I get back to school tomorrow. | October 13, 2004, 3:23 AM |
Myndfyr | 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 | October 13, 2004, 3:49 AM |
Super | 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. | October 13, 2004, 5:53 AM |
drivehappy | Maybe you should just create your own modal form with password masking textboxes? | October 13, 2004, 6:26 AM |
LivedKrad | [quote author=Super link=topic=9126.msg84178#msg84178 date=1097646832] 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. [/quote] Confused about what it does? [code] '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& [/code] 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.] [code] '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 [/code] 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 [] | October 17, 2004, 5:41 PM |