Visual BasiC语言 密码验证



我最近开始学习Visual Basic。

我想进行用户名和密码验证... 我将我的密码文本框命名为textPassword,将我的用户名文本框命名为textUser,将显示标签命名为display,并将提交按钮命名为submitBtn

这是(提交按钮的代码) :

if textUser = "Arya" then 
display.Text = "Username Is Correct!"
end if
if textPassword = "12345" then 
display.Text = "Password Is Correct!" 
end if

这是我得到的错误:

">

文本框"类型的值无法转换为"字符串">

请告诉我我的错误,以便我可以改变它... 谢谢!!!

正如其他评论所说,textUser 和 textPassword 是字段,因此您需要使用textUser.TexttextUser.Value来获取内部值。 通过执行"如果文本用户",您正在检查文本用户是否存在,因此它将返回 true。

最新更新