使用txt文件登录vb [英] making a login for vb using txt file
问题描述
Imports System.IO
Public Class loginscreen
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim objstreamreader As StreamReader
Dim strline As String
objstreamreader = New StreamReader("C:\Users\josh\Documents\computing project/user.txt.txt")
strline = objstreamreader.ReadLine()
Do While Not strline Is Nothing
If String.Equals(strline, TextBox1.text) And
String.Equals(strline, TextBox2.text) Then
strline = objstreamreader.ReadLine
MsgBox("correct")
Exit Do
Else
MsgBox("incorrect login details")
End If
Loop
objstreamreader.Close()
End Sub
End Class
我正在使用2个文本框进行登录,需要读取文件.这条路绝对是我保存它的方式是正确的.但是,每当我运行代码时,我得到的都是msgbox错误的登录详细信息.我该如何解决?我也认为我的txt文件可以格式化
I'm making a login using 2 textboxes and need to read a file. the pathway is definitely correct its the way I saved it. however whenever I run the code all I get is the msgbox incorrect login details. how do I fix this? also I think my txt file could be formatted
incorrectly how do I need my txt file to be set up?
推荐答案
我不知道,正斜杠对我来说似乎不正确" C:\ Users \ josh \ Documents \ computing project / user.txt.txt".另外,您使用文件扩展名 两次,文件名为"user.txt.txt";可能应该是"user.txt"代替.
I don't know, the forward slash looks fishy to me "C:\Users\josh\Documents\computing project/user.txt.txt". Plus you use the file extension twice with the file name "user.txt.txt" which maybe should be "user.txt" instead.
Plus this is basically double post of https://social.msdn.microsoft.com/Forums/en-US/1821ed20-1b95-446d-861e-ccacf2acaff1/creating-a-login-screen-with-vb-using-a-txt-file?forum=vbgeneral.
这篇关于使用txt文件登录vb的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!