Im trying to make a password input box but i dont know how to make it read and check if the password is right from file pwp.pw, so if password is right then it will let me come to form1.

This code is inside of form1 in form1_load

If File.Exists("pwp.pw") = True Then
            Dim myFileStream As FileStream
            Dim myStreamReader As StreamReader
            myFileStream = New FileStream("pwp.pw", FileMode.Open, FileAccess.Read)
            myStreamReader = New StreamReader(myFileStream)
            InputBox("Enter Password")
            If InputBox() = myStreamReader = True Then
                Me.ShowDialog()
            Else
                End
            End If

        End If

Recommended Answers

All 3 Replies

If InputBox() = myStreamReader = True <<< this never will be true (except both is nothing)

is there only one password in your pwp.pw file?
if so:

If InputBox("Enter Password") = myStreamReader.readtoend = True Then
                Me.ShowDialog()
            Else
                End
            End If
myStreamReader.close

Why does it not open my form ?

If File.Exists("pwp.pw") = True Then


            Dim myFileStream As FileStream
            Dim myStreamReader As StreamReader
            myFileStream = New FileStream("pwp.pw", FileMode.Open, FileAccess.Read)
            myStreamReader = New StreamReader(myFileStream)
            If InputBox("Enter Password") = myStreamReader.ReadToEnd = True Then

                Me.ShowDialog()

            Else

                End

            End If
        End If
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
	Dim mFile As String = IO.Path.Combine(My.Application.Info.DirectoryPath, "pwp.pw")
	 Try
	 Dim pass As String = New StreamReader(mFile).ReadToEnd
	 Dim tmpPass As String = InputBox("Enter password")
	 Debug.WriteLine("Password from file:{0} ; Password from Inputbox: {1}", pass, tmpPass)
	 If tmpPass <> pass Then
			  Me.Close()
	 End If
	 Catch ex As System.IO.FileNotFoundException
			  MsgBox("File not found")
			  Me.Close()
	 End Try

	End Sub

Check what is written in the Output window!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.