If any officer, required by § 15.2-1525 to be a resident at the time of his election or appointment of the county, city, town or district for which he is elected or appointed, or of the city wherein the courthouse of such county is or in a city wholly within the boundaries of such county, remove therefrom, except from the county to such city or from such city to the county, or in case a nonresident who has been elected attorney for the Commonwealth remove from the county or county seat of the county in which he resided when elected, except to the county in which he is elected, his office shall be deemed vacant.
Va. Code § 15.2-1526