Vác is well served by MÁV commuter trains from Budapest Nyugati station, forming the northern terminus of two lines. One is the Budapest - God - Vác route, which has 2 trains/h, takes 42 min to Vác, and costs 640 HUF (550 HUF with a Budapest travel card). The other one is the Budapest - Fót - Vác route, which has 1 train/h, takes 85 min and costs 915 HUF (735 HUF with a Budapest travelcard). You should thus only take a train going to Vác via Göd and ignore those running via Fót.
By car
From Budapest take road #2 or 2/A (E77)