It depends on the substance whose volume you know.
If you have a pure liquid or a solid you use its to calculate its mass and then divide the mass by the molar mass.
If you have a solution you multiply the by the volume in litres.
MOLES FROM VOLUME OF PURE LIQUID OR SOLID
There are two steps:
Example
How many moles are in 10.00 mL of acetic anhydride? The molar mass of acetic anhydride is 102.1 g/mol and its density is 1.080 g/mL?
Solution
The formula for density is
##color(blue)(|bar(ul(color(white)(a/a) = m/V color(white)(a/a)|))) ##
where #### is the density ##m## is the mass and ##V## is the volume of the sample.
We can rearrange the formula to get
##m = V ##
##mass = 10.00 color(red)(cancel(color(black)(mL))) 1.080 g/(1 color(red)(cancel(color(black)(mL)))) = 10.80 g##
##n = 10.80 color(red)(cancel(color(black)(g))) 1 mol/(102.1color(red)(cancel(color(black)(g)))) = 0.1058 mol##
MOLES FROM VOLUME OF SOLUTION
Molarity is the number of moles of a substance in one litre of solution.
##color(blue)(|bar(ul(color(white)(a/a) M = n/Vcolor(white)(a/a)|))) ##
where ##n## is the number of moles and ##V## is the volume in litres.
We can rearrange this equation to get the number of moles:
##n = M V##
Example
How many moles of ##NaCl## are contained in 0.300 L of 0.400 mol/L ##NaCl## solution?
Solution
##n = 0.300 color(red)(cancel(color(black)(L soln))) 0.400 mol NaCl/(1 color(red)(cancel(color(black)(L soln)))) = 0.120 mol NaCl##