Ships gain Veterancy points in game by dealing damage and taking damage. A ship can earn up to 10 VXP for damage earned and 10 VXP for damage taken. The more damage a fleet takes, the more VXP it earns for the combat; VXP for damage taken is calculated based on the percentage of armor remaining, which is why it is popular to rank ships without armor and then refit to add armor later.
Each ship’s VXP is calculated individually. So if you have a ship with all Anti-Mortars that doesn’t deal any damage to an enemy’s hull, it will not receive any VXP for doing damage though your fleet may have won the battle; it will still earn VXP for damage taken.