Detecting the space character
If Mid(str, i, strlength)
should be
If Mid(str, i, 1)
Start in position i for 1 character.
JN wrote:
Hi All,
I am trying to detect the space character in a string but my code is not
working.
Thanks for your help.
JN
sub demo()
Dim strlength As Integer
Dim str As String
str = "good morning"
strlength = Len(Trim(str))
For i = 1 To strlength
If Mid(str, i, strlength) = Chr(32) Then
MsgBox "space"
End If
Next i
End Sub
--
Dave Peterson
|