none
How To Make A One Time Password Protected Login....

    Question

  • On form1.load it loads up form2.... Form1 is not enabled unless form2 is completed right. If completed right remember not to show form2 and enable form1.  
    • Edited by Tj.. _ Friday, April 03, 2009 10:34 PM
    Friday, April 03, 2009 2:46 AM

Answers

  • in form2 ok button put

    If PasswordTextBox.Text = "123" And UsernameTextBox.Text = "tj" Then
                MsgBox("Your Product Is Now Registered. You Now Have Unlimited Version!")

                Form1.Enabled = True
                Me.Close()
            Else
                MsgBox("Wrong Product License", MsgBoxStyle.OkOnly)
                MsgBox("Will Now Close", MsgBoxStyle.Critical)
                End
            End If

    in the checkbox put (on form2)

    If CheckBox1.Checked Then
                My.Settings.Protection = UsernameTextBox.Text
                My.Settings.Protection2 = PasswordTextBox.Text
                My.Settings.Save()
                My.Settings.Reload()
            End If

    in form2. load put 

            UsernameTextBox.Text = My.Settings.Protection
            PasswordTextBox.Text = My.Settings.Protection2
            My.Application.SaveMySettingsOnExit = True


    on form1.load put 

    If My.Settings.Protection = "tj" And My.Settings.Protection2 = "123" Then
                Me.Enabled = True

                My.Settings.Save()
            Else
                LoginForm1Pro.Show()

            End If
    • Marked as answer by Tj.. _ Saturday, April 04, 2009 2:09 AM
    Saturday, April 04, 2009 2:09 AM

All replies

  • You can use ShowDialog (instead of Show) to force the user to close Form2 before continuing work on Form1.

        Private Sub Form1_Shown(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Shown
            Using f As New Form2
                If f.ShowDialog(Me) = DialogResult.OK Then
                    'Handle OK here.
                Else
                    'Handle Cancel here.
                End If
            End Using
        End Sub

    Form.Load is too early if you actually want Form1 to be visible (but not usable) on the screen while the user is working in Form2.  You could try Form.Shown instead.

    Friday, April 03, 2009 3:01 AM
  • You can try like this

    Private sub Form1_Load(...)
       Dim MyForm2 as New Form2
       MyForm2.ShowDialog()
       If MyForm2.DialogResult=Windows.Forms.DialogResult.Ok Then
         ' do something at here
       Else
         ' do something at here
       End If
    End Sub
    • Proposed as answer by tegezee Saturday, May 09, 2009 10:53 PM
    Friday, April 03, 2009 3:20 AM
  • But title say how to make one time login, How the log in is being done? I think You want remember username and password, kind of thing..

    If its simple like that and does  not depend on username, password changed later (if using database) then you can simply declare an Application Settings (Project Menu, Application properties, settings tab, create a setting called LoggedIn with user scope and boolean type)

    So once user logs in correctely in form2 you can set


    And in Form's Load(Copying Binary Coder'Code with permission :) )

    If Not My.Settings.LoggedIN Then

    Using f As New Form2
                If f.ShowDialog(Me) = DialogResult.OK Then
                     My.Settings.LoggedIN=True
                     My.Settings.Save()
    'Handle OK here. Else 'Handle Cancel here. End If End Using

    End If

    Remember if you have button ok and button cancel done from scratch, set Forms Acceptbuttoon and CancelButton properties 
    with those buttons or If user logs in Corectely in Form2
     Me.DialogResult=Windows.Forms.DialogResult.OK
    If Cancelled in Form2 then
     Me.DialogResult=Windows.Forms.DialogResult.Cancel

    Arjun Paudel
    Friday, April 03, 2009 3:43 AM
  • what about somthing like f = False (dont show form2 no more after completed right) 
    Friday, April 03, 2009 10:43 PM
  • it doesn't work
    Saturday, April 04, 2009 1:32 AM
  • Here's one MINE i just need it to save  (FORM1 IS DISABLED)


    Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
            If PasswordTextBox.Text = "123" And UsernameTextBox.Text = "tj" Then
                MsgBox("Your Product Is Now Registered. You Now Have Unlimited Version!")

                Form1.Enabled = True
                Me.Close()
            Else
                MsgBox("Wrong Product License", MsgBoxStyle.OkOnly)
                MsgBox(" Will Now Close", MsgBoxStyle.Critical)
                End
            End If
    Saturday, April 04, 2009 1:39 AM
  • I know you are struggling with basic, I have answered in my first post everything but you have not implemented, did you create setting?

    In betweent this, suggested blue line is missing, if you follow what you have been suggested you will get it working, but if you dont bother then how does it work

    Form1.Enabled = True
     Me.DialogResult=Windows.Forms.DialogResult.OK
    Me.Close()

    Post your form1 and form2 logic, probably we can help them, we cannot keep guessing what went wrong.

    Using setting is not a good way if it is really product registration, you might have to use registry or licence file or some other custom way.



    Arjun Paudel
    Saturday, April 04, 2009 1:46 AM
  • in form2 ok button put

    If PasswordTextBox.Text = "123" And UsernameTextBox.Text = "tj" Then
                MsgBox("Your Product Is Now Registered. You Now Have Unlimited Version!")

                Form1.Enabled = True
                Me.Close()
            Else
                MsgBox("Wrong Product License", MsgBoxStyle.OkOnly)
                MsgBox("Will Now Close", MsgBoxStyle.Critical)
                End
            End If

    in the checkbox put (on form2)

    If CheckBox1.Checked Then
                My.Settings.Protection = UsernameTextBox.Text
                My.Settings.Protection2 = PasswordTextBox.Text
                My.Settings.Save()
                My.Settings.Reload()
            End If

    in form2. load put 

            UsernameTextBox.Text = My.Settings.Protection
            PasswordTextBox.Text = My.Settings.Protection2
            My.Application.SaveMySettingsOnExit = True


    on form1.load put 

    If My.Settings.Protection = "tj" And My.Settings.Protection2 = "123" Then
                Me.Enabled = True

                My.Settings.Save()
            Else
                LoginForm1Pro.Show()

            End If
    • Marked as answer by Tj.. _ Saturday, April 04, 2009 2:09 AM
    Saturday, April 04, 2009 2:09 AM
  • EACH PRODUCT WILL HAVE AN INDIVIDUALLY PRODUCT KEY NOT ONE THE SAME.

    Saturday, April 04, 2009 2:16 AM
  • Thanks for the answer
    Arjun Paudel
    Saturday, April 04, 2009 2:53 AM
  • No problem, thanks for the help...
    Saturday, April 04, 2009 3:46 AM