In VB.NET:

codice:
MyVar = CDbl(MyVar).ToString("0000")
Se non convertite il valore da formattare in Double, non funge (almeno così mi sembra)

Ciao