我需要帮助,我用 1 个命令按钮和 4 个文本框制作了一个用户表单,我想做的是。如果所有 4 个 TextBox 仍然是空的,我想禁用 CommanButton。
我已经找到了一个仅对 1 个文本框有帮助的代码,我使用代码
私有子 TextBox1_Change()
如果 TextBox1.Value = "" 那么
CommandButton1.Enabled = False
别的
CommandButton1.Enabled = True
万一
结束子
当我在 textbox2 中使用相同的代码时,我最终卡住了,命令按钮被启用,当我使用代码(如果 TextBox1.value & textbox2.value & TextBox3.value & TextBox4.value = "" 然后 commandbutton1.enabled = false)命令填充 textbox1 后按钮仍然启用。
任何的想法 ?
您不需要任何 IF 条件。
CommandButton1.Enabled = cbool(Len(Textbox1.Text) + Len(Textbox2.Text) _
+ Len(Textbox3.Text) + Len(Textbox4.Text))
Run Code Online (Sandbox Code Playgroud)
CBool(x) = True 而 x 是除 0 以外的任何数字,在这种情况下,结果为 False。如果任何文本框有任何内容,它们的组合长度将大于 0,因此 CBool 的结果为 True。
| 归档时间: |
|
| 查看次数: |
5237 次 |
| 最近记录: |