登录表单发布vb.net
我正在创建一个学生数据管理系统,我被困在登录表单上。 我创建了一个注册表单,其中输入的详细信息保存在一个文本文件(Users.txt)中。 我似乎无法找出登录表单代码中的问题(粘贴在下面);它似乎无法识别任何保存的登录用户名和密码。 请帮忙。 谢谢 下面是注册表单的代码(文本如何保存到users.txt文件):登录表单发布vb.net,vb.net,login,Vb.net,Login,我正在创建一个学生数据管理系统,我被困在登录表单上。 我创建了一个注册表单,其中输入的详细信息保存在一个文本文件(Users.txt)中。 我似乎无法找出登录表单代码中的问题(粘贴在下面);它似乎无法识别任何保存的登录用户名和密码。 请帮忙。 谢谢 下面是注册表单的代码(文本如何保存到users.txt文件): 如果txtsername.Text=temp和txtspassword.Text=temp,那么您希望用户名和密码相等吗?另外,我猜Users.txt可能有几行包含多个用户/密码,因此您
如果txtsername.Text=temp和txtspassword.Text=temp,那么您希望用户名和密码相等吗?另外,我猜Users.txt
可能有几行包含多个用户/密码,因此您应该搜索该文件。为了帮助您,告诉我们Users.txt
saved中的信息如何保存也很重要。我还可以补充一点,您的user.txt文件数据应该(必须)加密。@DavidWilson如何加密数据?@Pikoh然后文本文件有几行。它以用户总数开始,然后是用户ID(从1开始,向上),然后是用户名和密码。如何搜索用户名?我已经添加了如何将文本保存到上述问题中的文件的代码。谢谢你的问题的答案太宽泛了,无法在这里发布,但是使用“vb.net加密用户密码文本文件”快速搜索google会产生75万个结果-看一看。如果txtusername.text=temp和txtpassword.text=temp,那么
你希望用户名和密码相等吗?另外,我猜Users.txt
可能有几行包含多个用户/密码,因此您应该搜索该文件。为了帮助您,告诉我们Users.txt
saved中的信息如何保存也很重要。我还可以补充一点,您的user.txt文件数据应该(必须)加密。@DavidWilson如何加密数据?@Pikoh然后文本文件有几行。它以用户总数开始,然后是用户ID(从1开始,向上),然后是用户名和密码。如何搜索用户名?我已经添加了如何将文本保存到上述问题中的文件的代码。谢谢你的问题的答案太宽泛了,无法在这里发布,但是使用“vb.net加密用户密码文本文件”快速搜索google会产生75万个结果——看一看。
Imports System.IO
Public Class Registration
Dim myfilewriter As StreamWriter
Dim myfilereader As StreamReader
Dim strMyFilename As String
Dim intNumofRecs As Integer
Dim temp As String
Structure Users
Dim intUserID As Integer
Dim strusername As String
Dim strpassword As String
End Structure
Dim UsersArray() As Users
Private Sub readindata()
Dim intCounter As Integer
strMyFilename = "Users.txt"
myfilereader = New StreamReader(strMyFilename)
intNumofRecs = myfilereader.ReadLine
ReDim Preserve UsersArray(intNumofRecs)
intCounter = 0
Do Until myfilereader.EndOfStream = True
intCounter = intCounter + 1
UsersArray(intCounter).intUserID = myfilereader.ReadLine()
UsersArray(intCounter).strusername = myfilereader.ReadLine()
UsersArray(intCounter).strpassword = myfilereader.ReadLine()
Loop
myfilereader.Close()
End Sub
Private Sub btnNewUser_Click(sender As Object, e As EventArgs) Handles btnNewUser.Click
Me.Hide()
Sign_Up.Show()
End Sub
Private Sub Registration_Load(sender As Object, e As EventArgs) Handles MyBase.Load
readindata()
End Sub
Private Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click
Dim username As Boolean = False
Dim password As Boolean = False
Dim temp As String
myfilereader = System.IO.File.OpenText("Users.txt")
temp = myfilereader.ReadToEnd
myfilereader.Close()
If txtusername.Text = temp And txtpassword.Text = temp Then
username = True
password = True
Else
MsgBox("User not found")
End If
If username And password = True Then
txtusername.Text = ""
txtpassword.Text = ""
Me.Hide()
Dashboard.Show()
Else
End If
End Sub
End Class
Public Sub SavetoTextFile()
Dim intCounter As Integer
readindata()
intNumofRecs = intNumofRecs + 1
ReDim Preserve UsersArray(intNumofRecs)
UsersArray(intNumofRecs).intUserID = intNumofRecs
UsersArray(intNumofRecs).strusername = txtUsername.Text
UsersArray(intNumofRecs).strpassword = txtPassword.Text
strMyFilename = "Users.txt"
myfilewriter = New StreamWriter(strMyFilename)
myfilewriter.WriteLine(intNumofRecs)
For intCounter = 1 To intNumofRecs
myfilewriter.WriteLine(UsersArray(intCounter).intUserID)
myfilewriter.WriteLine(UsersArray(intCounter).strusername)
myfilewriter.WriteLine(UsersArray(intCounter).strpassword)
Next
myfilewriter.Close()
End Sub
Private Sub btnSignUp_Click(sender As Object, e As EventArgs) Handles btnSignUp.Click
SavetoTextFile()
txtUsername.Text = ""
txtPassword.Text = ""
Me.Hide()
Registration.Show()
End Sub