Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. VB password help

VB password help

Scheduled Pinned Locked Moved Visual Basic
help
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    arranmc182
    wrote on last edited by
    #1

    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

    A P D 3 Replies Last reply
    0
    • A arranmc182

      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

      A Offline
      A Offline
      AliAmjad
      wrote on last edited by
      #2

      Just set the PasswordChar property of your TextBox to *.

      AliAmjad(MCP)

      A 1 Reply Last reply
      0
      • A arranmc182

        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

        P Offline
        P Offline
        Paul Conrad
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • A AliAmjad

          Just set the PasswordChar property of your TextBox to *.

          AliAmjad(MCP)

          A Offline
          A Offline
          arranmc182
          wrote on last edited by
          #4

          "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

          A 1 Reply Last reply
          0
          • A arranmc182

            "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

            A Offline
            A Offline
            AliAmjad
            wrote on last edited by
            #5

            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)

            1 Reply Last reply
            0
            • A arranmc182

              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

              D Offline
              D Offline
              Dan Suthar
              wrote on last edited by
              #6

              Hi, You can simply use the MaskedTextBox from the toolbox. Then set its password char to "*" . :) Thanks, Dan

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups