I have written a program to find the length of last word.Please tell me where I am wrong.

Dim a As String
Console.WriteLine("Enter a string")
a = Console.ReadLine

Dim lastWordLength As Integer
Dim beforeFirstNonEmptyChar As Integer
lastWordLength = 0
beforeFirstNonEmptyChar = True

If a.Length = 0 Then
Console.Write(lastWordLength)
End If

For i = a.Length - 1 To 0
If a(i) = " " Then
lastWordLength = lastWordLength + 1
beforeFirstNonEmptyChar = False
ElseIf beforeFirstNonEmptyChar Then
Exit For
End If
Next

Console.WriteLine(lastWordLength)
Console.ReadLine()
End Sub

2 answers

How do you know there's anything wrong? Have you run it to see whether it works? If not, what happens?
It doesn't work.
Similar Questions
  1. The concept of program music refers to(1 point) Responses the music being written by a computer program. the music being written
    1. answers icon 1 answer
    1. answers icon 1 answer
    1. answers icon 1 answer
  2. he concept of program music refers to(1 point) Responses the music being written by a computer program. the music being written
    1. answers icon 1 answer
more similar questions