Hi Abrar,
I have felt your pain at some point in my life. The point was that I did not know that string compares differently from ints.The quotations in a string mean a lot and simple tab space does not equal to space. My apologies for posting a reply in vbscript but this is what I used and helped me get my sleep back.
Function CleanString(strSource)
'On Error GoTo CleanStringErr
' convert tabs to spaces first
strSource = Replace(strSource, vbTab, " ")
' convert all CRLFs to spaces
strSource = Replace(strSource, vbCrLf, " ")
' Find and replace any occurences of multiple spaces
Do While (InStr(strSource, " "))
' if true, the string still contains double spaces,
' replace with single space
strSource = Replace(strSource, " ", " ")
Loop
' Remove any leading or training spaces and return
' result
CleanString = Trim(strSource)
Exit Function
'CleanStringErr:
' Insert error-handling code here
End Function
Cheers,
Mpho