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. Password Problem

Password Problem

Scheduled Pinned Locked Moved Visual Basic
helpsecuritytutorialquestion
3 Posts 2 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.
  • D Offline
    D Offline
    Dave McCool
    wrote on last edited by
    #1

    I have a form which has a button called "Modify Intrest" and when you click it, it brings up a password box and asks for the password. What I wanted was if password was typed in wrong three times, a message to display and then when you click OK, the application to close. If you type the password in correctly, I want an intrest rate box to display and you have to type in a number and it is written to a file ir.txt Here is code I have: Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click If txtIntrest.Text = ("") Then MsgBox("Please Enter Intrest Rate", MsgBoxStyle.Exclamation) Exit Sub End If If Not txtIntrest.Text.Equals(myline) Then Static passnum As Integer Do Dim pass As String = InputBox("Enter the Password", "Enter Password", "", ) If pass = "Password" Then Dim intrest As String = InputBox("Enter The New Intrest", "Enter Intrest Rate", "", ) txtIntrest.Text = (intrest) Dim theFile As FileStream = File.Create("ir.txt") Dim writer As StreamWriter = New StreamWriter(theFile) writer.WriteLine(txtIntrest.Text) writer.Close() theFile.Close() Exit Sub Exit Do Else Loop Until passnum = 3 passnum = +1 End If MsgBox("You have had three attempts to input password, Program will now close for security reasons", MsgBoxStyle.Critical) Application.Exit() End If End Sub I messed it up slightly and not sure how to fix it, any ideas?

    In the end we're all just the same

    C 1 Reply Last reply
    0
    • D Dave McCool

      I have a form which has a button called "Modify Intrest" and when you click it, it brings up a password box and asks for the password. What I wanted was if password was typed in wrong three times, a message to display and then when you click OK, the application to close. If you type the password in correctly, I want an intrest rate box to display and you have to type in a number and it is written to a file ir.txt Here is code I have: Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click If txtIntrest.Text = ("") Then MsgBox("Please Enter Intrest Rate", MsgBoxStyle.Exclamation) Exit Sub End If If Not txtIntrest.Text.Equals(myline) Then Static passnum As Integer Do Dim pass As String = InputBox("Enter the Password", "Enter Password", "", ) If pass = "Password" Then Dim intrest As String = InputBox("Enter The New Intrest", "Enter Intrest Rate", "", ) txtIntrest.Text = (intrest) Dim theFile As FileStream = File.Create("ir.txt") Dim writer As StreamWriter = New StreamWriter(theFile) writer.WriteLine(txtIntrest.Text) writer.Close() theFile.Close() Exit Sub Exit Do Else Loop Until passnum = 3 passnum = +1 End If MsgBox("You have had three attempts to input password, Program will now close for security reasons", MsgBoxStyle.Critical) Application.Exit() End If End Sub I messed it up slightly and not sure how to fix it, any ideas?

      In the end we're all just the same

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Dave McCool wrote:

      Loop Until passnum = 3 passnum = +1 End If

      You need to show the password dialog again inside this loop and check if it is entered right. This code doesn't allow anyone to try again.

      Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      D 1 Reply Last reply
      0
      • C Christian Graus

        Dave McCool wrote:

        Loop Until passnum = 3 passnum = +1 End If

        You need to show the password dialog again inside this loop and check if it is entered right. This code doesn't allow anyone to try again.

        Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

        D Offline
        D Offline
        Dave McCool
        wrote on last edited by
        #3

        Thanks, but I am not 100% sure how to do this. I took out the code so it looks like this: Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click If txtIntrest.Text = ("") Then MsgBox("Please Enter Intrest Rate", MsgBoxStyle.Exclamation) Exit Sub End If If Not txtIntrest.Text.Equals(myline) Then Dim pass As String = InputBox("Enter the Password", "Enter Password", "", ) If pass = "Password" Then Dim intrest As String = InputBox("Enter The New Intrest", "Enter Intrest Rate", "", ) txtIntrest.Text = (intrest) Dim theFile As FileStream = File.Create("ir.txt") Dim writer As StreamWriter = New StreamWriter(theFile) writer.WriteLine(txtIntrest.Text) writer.Close() theFile.Close() Exit Sub End If End If End Sub So the password box just closes when the wrong password is input. I want the password box to keep displaying istead of closing and if you type password wrong three times, this code to execute: MsgBox("You have had three attempts to input password, Program will now close for security reasons", MsgBoxStyle.Critical) Application.Exit() but I was told I could do this with a loop, but was not sure how I had code: Static passnum As Integer Do passnum = +1 Loop Until passnum = 3 but was not sure where to put it so it worked, any ideas?

        In the end we're all just the same

        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