vb.net - 如果登录详细信息错误,向用户显示消息?
问题描述
如果用户输入错误的登录详细信息,我该如何做到这一点,他们会收到错误消息?我试过的东西不起作用,当我按下按钮时没有任何反应
Private Sub Loginbtn_Click(sender As Object, e As EventArgs) Handles Loginbtn.Click
'Allows user into app with specifc username & password (Login ID 1)
If Usernamebtn.Text = "Business1" And Passwordbtn.Text = "qwerty1" Then
MsgBox("You are Logged In!", MessageBoxIcon.Information, "Login")
AppMenu.Show()
Me.Hide()
Else
'If no username or password field empty
If Usernamebtn.Text = "" Or Passwordbtn.Text = "" Then
MsgBox("Please Fill in the Username and Password!", MsgBoxStyle.Critical, "Error")
'If no username or password dosent match Login ID
If Usernamebtn.Text <> "Business1" AndAlso Passwordbtn.Text = "qwerty1" Then
MsgBox("Dosen't Exist, Please try again.", MsgBoxStyle.Critical, "Error")
Else
End If
End If
End If
End Sub
解决方案
试试这个方法
Private Sub Loginbtn_Click(sender As Object, e As EventArgs) Handles Loginbtn.Click
'Allows user into app with specifc username & password (Login ID 1)
If Usernamebtn.Text = "Business1" AndAlso Passwordbtn.Text = "qwerty1" Then
MsgBox("You are Logged In!", MessageBoxIcon.Information, "Login")
AppMenu.Show()
Me.Hide()
Else
'If username or password field empty
If Usernamebtn.Text = "" OrElse Passwordbtn.Text = "" Then
MsgBox("Please Fill in the Username and Password!", MsgBoxStyle.Critical, "Error")
Else
MsgBox("User dosen't exist OR password incorrect, Please try again.", MsgBoxStyle.Critical, "Error")
End If
End If
End Sub
会发生一些事情。
推荐阅读
- c - C 编程 - 在信号处理程序中计数信号
- java - 如何在二维图像数组中存储和显示图块?
- r - 根据变量名的第一个字母将数据整形为长格式
- node.js - 使用 webhook 在我的服务器上更新不起作用
- node.js - Azure Blob 存储在上传完成之前返回 200 状态,导致出现争用情况
- javascript - 将应用程序部署到 Heroku,ENV 变量不工作
- javascript - 如果我添加反应删除频道
- android - 如何在 Android Studio 和 IntelliJ IDEA 项目中共享 Kotlin 格式约定?
- javascript - 在 HTML 中格式化
- ios - 如何将两个 vImage_Buffers 合并为一个 CVPixelBuffer