View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tim Williams Tim Williams is offline
external usenet poster
 
Posts: 1,588
Default Detecting the space character

Why not use Instr() ?

In any case, maybe you could try
....
If Mid(str, i, 1) = Chr(32) Then
....

Tim

--
Tim Williams
Palo Alto, CA


"JN" wrote in message
...
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