VB.NET 如何检查用户名和密码文本框是否不为空?

问题描述 投票:0回答:1

有没有办法检查两个文本框(用户名,密码)是否有文本?我想在启用连接按钮之前检查一下。

我尝试使用两个 if 语句,例如

if not user.text = "" then
buttonlogin.enabled = true
end if

if not password.text = "" then
buttonlogin.enabled = true
end if

但是如果其中一个按钮获得文本而不是两者都获得文本,则该按钮将被启用。

谢谢你。 :)

vb.net
1个回答
0
投票

尝试

if string.IsNullOrEmpty(strings.trim(user.text)) then
     buttonlogin.enable = false
else
     buttonlogin.enable = true
endif

密码也一样。

© www.soinside.com 2019 - 2024. All rights reserved.