To explain further, those "white-spaces" are null characters represented as CHR$(0). They are added to strings less than their dimension limits, so text = "abc" would be recorded as abc with 277 CHR$(0) characters following the "c" in your DIM text as STRING * 300 example.
Fell's line of code will strip the null characters off your text variable.
Pete
Just half of the truth, usually a regular assignment such as text = "abc" does fill the remaining 277 (or whatever) bytes with spaces on fixed length strings, but if you're just replacing chars in the form MID$(text, 1, 3) = "abc", then the other bytes remain uninitialized, hence CHR$(0).
That's why I usually do a xxx = "" on any fixed length strings first anywhere in my program's init procedure, it will make it all spaces and then you can also use MID$ for char replacement without leaving the other parts uninitialized, as they are already spaces after the first assignment.
BTW - xra7en, that's also the reason that it works, once you have edited/assigned it once.