Jump to content

Form de login


Recommended Posts


O código em baixo é um Form de Login

lê um ficheiro de Password referente ao mês actual.

Agora precisava de ajuda ,era para mostrar a password na Textbox1.

Alguém para dar uma ajudinha?

Public Class PassForm

Private Const key As Integer = &H9A
Private Const PassFile As String = "d:\pass.cod"   ' Ficheiro password

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnOpen.Click

	   Dim Pass = GetCurrentMonthPassword()

	Textbox1.Text = Pass Then

	 Textbox1.Text = String.Empty
	End If
End Sub

Private Function GetCurrentMonthPassword() As String

	If Not System.IO.File.Exists(PassFile) Then
		MsgBox("Não foi possível encontrar o ficheiro " & PassFile, MsgBoxStyle.Critical)
	End If

	Dim PwdBytes = System.IO.File.ReadAllBytes(PassFile)

	Dim i = 0
	Dim nbytes = PwdBytes.Count()

	Dim m = 1
	Dim month = Now.Month

	While i < nbytes And m < month
		Dim ch = PwdBytes(i) Xor key
		If ch = &HA Then m += 1
		i += 1
	End While

	Dim PwdBuilder As New System.Text.StringBuilder(50)

	While i < nbytes
		Dim ch = PwdBytes(i) Xor key
		If ch = &HA Then Exit While
		i += 1
	End While

	Return PwdBuilder.ToString()
End Function

End Class

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.