Te paso un ejemplo de como te quedaría:
Cita: Private Function GetZeros(ByVal iNum As Integer, ByVal iLimit As Integer) As String
Dim iLength As Integer = iNum.ToString.Length
Dim s As String
If iLength < iLimit Then
For i As Integer = 1 To iLimit - iLength
s += "0"
Next
s += iNum.ToString
Else
s = "Error"
End If
Return s
End Function
Y para llamarla:
Cita: Response.Write(GetZeros(312, 9))
Salu2