0

I am trying to add a length check in my coffee shop program... i have sorted some of it out but i cant see where I am going wrong.

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
SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964

1 Answers1

3
Len(Name <= 3) 

This code doesn't make any sense.

You're checking whether Name (a string) is less or equal to than 3 (huh?), then getting the Len() of the result of that check. (huh?)

You probably want to get the Len() of the string (Len(Name)), then check whether the result of that (which is a number) is less than or equal to 3.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • 2
    +1. Yes, he probably meant Len(Name) <= 3, but even then I would recommend using `Name.Length <= 3`, to keep it more .NET-ish. – Victor Zakharov Jan 20 '13 at 15:06