Non ho ben chiaro il problema.

cmq:
codice:
Dim s as string
s=" hello world "
s=s.replace(" ", "")
restituisce
s="helloworld"