Babar Firasat
Babar Firasat

Reputation: 1

In Visual Basic, I keep getting String To double Error

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

Upvotes: 0

Views: 272

Answers (1)

SLaks
SLaks

Reputation: 887777

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.

Upvotes: 3

Related Questions