If we begin with the fact that you have $7 which you pay for the dress, and then you sell the dress for $8, and thus you have $8, i.e. one dollar more.
You then borrow $1, and thus together you have $9.
You go to the store and buy a dress for $9, after which you sell it for $10.
You then give $1 back to the person you borrowed it from.
That means that now you have $9, and that is $2 more than you had in the begining.