How to determine the coin amount needed for vin? At first I believed the coin amount of vin just based on what the send thinking. but after read some source code, it seems the coin amount of vin calculated from vout. Is anyone clear about this and please explain how the determination process is in source code. Thanks.
it seems the coin amount of vin calculated from vout.


It is. vin just references a vout from a previous transaction. Each output (vout) are referenced with the txid and an index (e.g. 0 or 1, because there can be multiple outputs in the same tx).

For more information about how transaction inputs and outputs work, see In getrawtransaction, what is the vout integer in the vin list?