Removing spaces from a string

How can I remove spaces from a string taken from an input text box. I am guessing I will have to use a for loop of some kind as I don’t know where the spaces will be until the user has filled in the text box.