# generate numbers

hello,
I would like to generate a list of numbers.
the code bellow is working fine but I just want to know how to add a feature.. so that the first digit has a range of [2-9] if it starts with 1 or 0 then its invalid

``````                    For x = 1 To 9999999
Debug.Print(x.ToString("D7"))
Next
``````
LVL 1
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
if x>=2 and x<=9
then
For x = 1 To 9999999
Debug.Print(x.ToString("D7"))
Next
Else
Error..
End If
0
Author Commented:
that code is not working
0
Commented:
try this

For x As Integer = 1 To 9999999
If x.ToString Like "[2-9]*" Then
Debug.Print(x.ToString("D7"))
End If

Next
0
Author Commented:
not working either.. getting numbers like
0876352
etc..
0
Commented:
so you want to check it after the format? then you can start the loop from 200000 instead of 1

For x As Integer = 200000  To 9999999
If x.ToString Like "[2-9]*" Then
Debug.Print(x.ToString("D7"))
End If
Next

or

For x As Integer = 1To 9999999
If x.ToString("D7") Like "[2-9]*" Then
Debug.Print(x.ToString("D7"))
End If
Next
0

Experts Exchange Solution brought to you by