Oh yes!
I usually use the HTML <PRE> and </PRE> tags around my code fragment to do this, although there are UBB CODE tags that can do this too (click on the "UBB Code is ON" link when you are writing a message for more info).
Some forums have HTML turned off, so you would need to use the UBB tags.
[This message has been edited by
Paul Wheaton (edited August 27, 2000).]