If you sell an asset, you have its value on a list of assets. You also should have a record of how much it has been depreciated. To enter the sale in your accounting records, you enter the cash from the sale in the cash account. Then, you balance that entry with a credit to the account for that particular asset, and a debit to the accumulated depreciation account. The difference is your gain, or loss, on that sale.
As an example, you sell a truck which you bought for $6,780. It has depreciated by $3,200. You managed to sell it for $5,400. The entry to record this sale would be as follows:
|1300 Fixed Assets - truck||$6,780|
|1301 Accum. Depreciation||$3,200|
|7100 Gain (or loss) on the sale||$1,820|
If your balancing entry had been a debit, it would have meant you lost money on the sale. Here's how to think about it: You paid $6,780. On your books, its value had decreased by $3,200, meaning you had expensed out that amount of money over the period of time you had the truck. So, to you it's actually worth $3,580, and you sold it for $5,400, which was a gain of $1,820.