初学vb,求教个关于按钮可用不可用的代码

来源:百度知道 编辑:UC知道 时间:2024/05/04 03:30:00
text1为空时command1不可用,当在text1中输入时,command1即变为可用;当text1被清空后command1再次变为可用
以上代码怎么写?

private sub text1_change()
command1.enabled = (text1.text <> "")
end sub

以上代码的完整版本:
private sub text1_change()
if (text1.text = "")=true then
command1.enabled = false
else
command1.enabled = true
end if
end sub

Private Sub Text1_Change()
Command1.Enabled = IIf(Len(Text1.Text) <> 0, 1, 0)
End Sub