Say you are writing all $d$ digit numbers, writing leading zeros. Then you would write out $d\times 10^d$ digits total, with each digit occurring exactly $\frac{1}{10}$th of the time, so you would write a total of $d\times 10^{d-1}$ zeros.
So, for example, to write all numbers between $0$ and $99$, writing the numbers less than $10$ as $0d$, you would write $2\times 10^2 = 200$ digits, of which $2\times 10=20$ are zeros.
Of course, of these you don't want to count the leading $0$s of $00-09$, so you subtract $10$; and you don't want to count the second $0$ from $00$, so you subtract another one, giving you a total of $9$ zeros. So you need to adjust the count above.
If you write all numbers of up to $d$ digits, then the number of $0$s, including leading $0$s, is $d\times 10^{d-1}$. Then you subtract the number of leading $0$s that appear in the left-most digit (there are $10^{d-1}$ of them), those that appear in the second-left-most digit when the left-most is $0$ (there are $10^{d-2}$ of them); those that appear in the third left-most digit when the first two are $0$ (there are $10^{d-3}$ of them) and so on. So you get
$$d\times 10^{d-1} - (1+10+10^2+\cdots + 10^{d-1}) = \frac{(9(d-1)-1)10^{d-1} + 1}{9}.$$
So, for example, for $d=2$ (from $1$ through $99$), you get
$$\frac{(9-1)10^1 + 1}{9} = \frac{81}{9} =9,$$
same as above. For $d=3$, (from $1$ through $999$) you get
$$\frac{(9(2) - 1)10^2 + 1}{9} = \frac{1701}{9} = 189.$$
What if you are doing something slightly different, as you write, say, only the numbers between $1$ and $751$?
You can count the zeros from $1$ to $99$ as above.
Then count the number of zeros in numbers of the form $7bx$ with $1\leq b\leq 5$. There's one for each value of $b$, for a total of $5$.
Then count the number of zeros in numbers of the form $70x$; there's $11$ of them.
Then count the number of zeros in numbers of the form $axy$ with $1\leq a\leq 6$; there's $10^{2-1}=10$ of them (you are just counting all zeros in numbers up to 2 digits, counting leading $0$s).
So after counting all the way to $99$, you then add:
- One zero for each number $7bx$, $1\leq b\leq 5$: total, $5$ (the middle digit of $751$).
- Zeros for each number $70x$; total, $11$.
- Zeros for each number $axy$ with $1\leq a\leq 6$; total, $6\times 10^{2-1} = 60$.
There are 9 zeros from $1$ through $99$; and then there are $60+11+5=76$ zeros from $100$ through $751$, for a total of $85$ zeros from $1$ through $751$.