我想在我的咖啡店计划中添加长度检查... 我把它中的一部分排除了,但我不知道我哪里出错了。
Dim Name As String
MsgBox("Welcome. You Are On The 'Hot Mornings' Self-Ordering Service", vbInformation, "Welcome To Hot Mornings!")
Name = InputBox("Please Enter Your Name", "Welcome To Hot Mornings!", , MsgBoxStyle.OkCancel)
If Len(Name <= 3) Then
Do Until Len(Name > 3)
MsgBox("Error!", vbExclamation, MsgBoxStyle.OkOnly)
MsgBox("An Error Occureed Earlier. We Are Currently Trying To fix This Issue.", vbInformation, "Error!")
Name = InputBox("Please Enter Your Name.", , "Must Contain More Than 3 Characters", MsgBoxStyle.OkCancel)
Loop
End If
答案 0 :(得分:3)
Len(Name <= 3)
这段代码没有任何意义。
您正在检查Name
(字符串)是否小于或等于3(是吧?),然后获取该检查结果的Len()
。 (啊?)
您可能想要获取字符串Len()
(Len(Name)
),然后检查该结果(这是一个数字)是否小于或等于3.