locked
PasswordBox Help

    Question

  •  

    So, I made this program. It's very simple, but it doesn't really matter what is is. I'm looking to add a PasswordBox to the program. Preferably that it wont show the actual program till you get the password right, but if that's very very hard, I'd settle with, lets say, typing it into a textbox and needing it to use the "Start" button of the program. How would I go about adding this? Before anyone yells at me saying I should go look at help page, I did, it wasn't very helpful. Smile

     

    Thanks in advance!

    Tuesday, October 23, 2007 11:56 PM

Answers

  • You could use something like a login form where the user must write the password. Then is the password is correct you open the main form of your program. It is actually quite easy. In the login form form you should have a textbox and a button. Then you can use something like this

     

    Public Class frmLogin

     

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click

     

    Dim Password As String = "123456789"

     

    If textbox1.text=password Then

     

    frmMain.Show()

     

    End If

     

    End Sub

     

    End Class

    Wednesday, October 24, 2007 9:40 AM
  • Hi Roflcopter,

     

    Based on your post, my understanding of your question is that you need to restrict access of your application.

     

    RMS81 has given right direction. I only give some suggestion to this problem. When we add a logon form to the application, we need to customize Sub Main() procedure as the entry point and to start the Application. We first execute the sub main() procedure to show login form/splash form, then call Application.Run(form1) to begin running a standard application message loop on the current thread, and makes from1 visible. As long as form1 is open the application continues to run.  Once form1 is closed the application will end.  For more information about Sub Main() procedure, please visit: http://www.getdotnetcode.com/GdncStore/free/Articles/VB%20NET%20Sub%20Main%20Procedure.htmOf course we also can set “project property-> Application-> ShutDown mode” property to achieve this.  Hope this helps.

    Best regards,

    Riquel

     

    Friday, October 26, 2007 8:46 AM
    Moderator

All replies

  •  

    While it probably doesn't matter or help much, here's my code:

     

     

     

    Code Block

    Public Class Form1

     

     

    Private Sub Command1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

     

     

    Dim Address As String = TextBox1.Text

    Dim Parameter As String = TextBox2.Text

    Dim PacketSize As String = TextBox3.Text

    Dim NumPrompts As Integer

    If IsNumeric(TextBox4.Text) = False Then

    NumPrompts = 1

    Else

    NumPrompts = Convert.ToInt32(TextBox4.Text)

    End If

    For index As Integer = 1 To NumPrompts

    Process.Start("ping", Address & " " & Parameter & " " & PacketSize)

    Next

    End Sub

     
    Wednesday, October 24, 2007 12:23 AM
  • You could use something like a login form where the user must write the password. Then is the password is correct you open the main form of your program. It is actually quite easy. In the login form form you should have a textbox and a button. Then you can use something like this

     

    Public Class frmLogin

     

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click

     

    Dim Password As String = "123456789"

     

    If textbox1.text=password Then

     

    frmMain.Show()

     

    End If

     

    End Sub

     

    End Class

    Wednesday, October 24, 2007 9:40 AM
  • Hi Roflcopter,

     

    Based on your post, my understanding of your question is that you need to restrict access of your application.

     

    RMS81 has given right direction. I only give some suggestion to this problem. When we add a logon form to the application, we need to customize Sub Main() procedure as the entry point and to start the Application. We first execute the sub main() procedure to show login form/splash form, then call Application.Run(form1) to begin running a standard application message loop on the current thread, and makes from1 visible. As long as form1 is open the application continues to run.  Once form1 is closed the application will end.  For more information about Sub Main() procedure, please visit: http://www.getdotnetcode.com/GdncStore/free/Articles/VB%20NET%20Sub%20Main%20Procedure.htmOf course we also can set “project property-> Application-> ShutDown mode” property to achieve this.  Hope this helps.

    Best regards,

    Riquel

     

    Friday, October 26, 2007 8:46 AM
    Moderator