登录表格问题 [英] Login Form Problem

查看:70
本文介绍了登录表格问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个登录屏幕,它将能够检查文件是否存在并抛出错误消息.问题是,如果我使用(<> = True),即使文件不存在,它也会引发错误消息.如果我仅使用(= True),则根本不会引发错误消息.以下是我正在使用的代码.提前谢谢.

Hi, I''m making a login screen that will be able to check to see if a file exists and throw an error message. The problem is that if I use (<> = True), even if the file does not exist it throws the error message. If I use just (= True) it does not throw error message at all. Below is the code I''m using. Thanks in advance.

Private Sub btnCreateUser_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreateUser.Click
        Dim namefile As String
        namefile = txtCUserName.Text
        If namefile = "" Then
            MsgBox("Please Enter A Username")
            txtCPassword.Focus()
        Else : If txtCPassword.Text = "" Then
                MsgBox("Please Enter A Password")
            Else : If My.Computer.FileSystem.DirectoryExists("C:\AccountUsers\") Then
                Else
                    MkDir("C:\AccountUsers\")
                End If
            End If
        End If
        If My.Computer.FileSystem.FileExists("/txtCUserName.txt") <> True Then
            MsgBox("Account Already Exists, Use A Different Username Or Login", MsgBoxStyle.Information)
            txtCUserName.Text = ""
            txtCPassword.Text = ""
            txtCUserName.Focus()
        Else
            FileOpen(1, "C:\AccountUsers\" + namefile + ".txt", OpenMode.Output, OpenAccess.Write)
            PrintLine(1, txtCUserName.Text)
            PrintLine(1, txtCPassword.Text)
            FileClose(1)
            txtCUserName.Text = ""
            txtCPassword.Text = ""
            txtCUserName.Focus()
        End If
    End Sub

推荐答案

首先,当您执行此类操作时,应指定完整的限定路径.其次,请尝试以下操作:

First, you should specify the entire qualified path when you''re doing something like this., Second, try this:

If My.Computer.FileSystem.FileExists("/txtCUserName.txt") Then
...
else
...
end if


前行在FileExists参数中斜线("/")并完全丢失<> True"部分.

这是什么?您是在将用户名和密码写成纯文本格式的文本文件吗?如果您这样做,则似乎不必担心安全性.
Get ride of the forward slash ("/") in the FileExists parameter and lose the "<> True" part entirely.

What is this? You''re writing the users name and password into a text file in clear text?? Security doesn''t seem to be a worry if you''re doing this.


这篇关于登录表格问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆