VB password help
-
im trying to make a program that makes u enter a password inorder to use a program the only problem is that u can see the pass word that istyped i would like to hide it so u just see *** insted of text here is my code .......................................... Public Class Form Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Password As String Dim InputPassword As String Dim Attempt As Integer Password = "test" Attempt = 0 Do InputPassword = InputBox("Enter password. This is attempt number " & Attempt & ".") Attempt = Attempt + 1 Loop Until (Attempt = 3) Or (InputPassword = Password) If InputPassword = Password Then MsgBox("This password is valid!") Dim F1 As New Form1() F1.Show() Else MsgBox("This password is invalid!") End If End Sub End Class
-
im trying to make a program that makes u enter a password inorder to use a program the only problem is that u can see the pass word that istyped i would like to hide it so u just see *** insted of text here is my code .......................................... Public Class Form Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Password As String Dim InputPassword As String Dim Attempt As Integer Password = "test" Attempt = 0 Do InputPassword = InputBox("Enter password. This is attempt number " & Attempt & ".") Attempt = Attempt + 1 Loop Until (Attempt = 3) Or (InputPassword = Password) If InputPassword = Password Then MsgBox("This password is valid!") Dim F1 As New Form1() F1.Show() Else MsgBox("This password is invalid!") End If End Sub End Class
-
im trying to make a program that makes u enter a password inorder to use a program the only problem is that u can see the pass word that istyped i would like to hide it so u just see *** insted of text here is my code .......................................... Public Class Form Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Password As String Dim InputPassword As String Dim Attempt As Integer Password = "test" Attempt = 0 Do InputPassword = InputBox("Enter password. This is attempt number " & Attempt & ".") Attempt = Attempt + 1 Loop Until (Attempt = 3) Or (InputPassword = Password) If InputPassword = Password Then MsgBox("This password is valid!") Dim F1 As New Form1() F1.Show() Else MsgBox("This password is invalid!") End If End Sub End Class
arranmc182 wrote:
Password = "test"
It is considered a bad idea to have plaintext passwords embedded right in your code. I hope you plan on using some crypto algorithm.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
-
"Just set the PasswordChar property of your TextBox to *. " i would do that but i carnt as i only mad a form that says click here to log in with a button then i put all the code on that so i carnt load up the for for when coding to do that im not realy bother how the code is as long as it works in some way cus this is for college and they dont care what code we use as long as it works
-
"Just set the PasswordChar property of your TextBox to *. " i would do that but i carnt as i only mad a form that says click here to log in with a button then i put all the code on that so i carnt load up the for for when coding to do that im not realy bother how the code is as long as it works in some way cus this is for college and they dont care what code we use as long as it works
Why are you choosing a difficult way when you can easily do this with the functionality provided by the .NET Framework otherwise you have to adopt a difficult way by using APIs to get the current key pressed store it into a StringBuidler object assign a * to the inputbox for key pressed and repeat the process to get the work done and I think you should have looked at Rule No. 9 before even creating this thread.
AliAmjad(MCP)
-
im trying to make a program that makes u enter a password inorder to use a program the only problem is that u can see the pass word that istyped i would like to hide it so u just see *** insted of text here is my code .......................................... Public Class Form Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Password As String Dim InputPassword As String Dim Attempt As Integer Password = "test" Attempt = 0 Do InputPassword = InputBox("Enter password. This is attempt number " & Attempt & ".") Attempt = Attempt + 1 Loop Until (Attempt = 3) Or (InputPassword = Password) If InputPassword = Password Then MsgBox("This password is valid!") Dim F1 As New Form1() F1.Show() Else MsgBox("This password is invalid!") End If End Sub End Class
Hi, You can simply use the MaskedTextBox from the toolbox. Then set its password char to "*" . :) Thanks, Dan