vb中需要输入相应的数字才能使用其他功能的代码

来源:百度知道 编辑:UC知道 时间:2024/06/21 15:30:18
同上

用一个Textbox和两个command按钮测试效果,刚开始command1不能用,输入12345,点击command2就可以使用了。根据情况用吧!
Private Sub Command2_Click()
If Text1.Text = "12345" Then
Command1.Enabled = True
Else
MsgBox "口令不正确", vbInformation, "提示"
Text1.SetFocus
End If
End Sub

Private Sub Form_Load()
Command1.Enabled = False
End Sub

算法可以这么算:
1.将你所谓的“其他功能”,写成函数模块。
2.添加一个模块,用于判断输入的数字,然后根据具体的数字调用相应的函数。