How do they Calculate Distances to the Stars?
Distance is usually measured with a ruler, measuring tape or a wheel. All these techniques rely on us being able to physically measure the distance between two points, but for stars and planets, this isn't very practical. Instead of measuring, astronomers have to calculate these values and they do this using a variety of methods.
For Close Objects
For objects up to around a few hundred light years we can use parallax shift. The technique is described in more detail in another article, but essentially the smaller the parallax shift, the further away the object is.
You can read about Parallax shift and distance in this article.
After a few hundred light years distance, parallax shift is so small it cannot be recorded, which makes this technique ineffective.
For Far Objects
Beyond 100 light years, but within our own galaxy, we can use a technique called distance modulus. Using the distance modulus it is possible to establish a relationship between the absolute magnitude of a star, its apparent magnitude, and its distance.
Calculate distances to the stars using distance modulus.
For Very Far Objects (Another Galaxy)
For objects outside our galaxy we can use the unique properties of a Cepheid variable star. These stars vary in brightness over time, in a frequency that is exactly in ratio to its apparent brightness, thus we can measure its frequency and its brightness and compute how far away it is using distance modulus. Every galaxy has a bunch of Cepheid variables, so its quite easy to map fairly accurate distances of all the galaxies we can see.