# format number generator

hello,
im using the code bellow to generate 8 million unique numbers but I need to add a feature where the first three digits are NXX and and XX cannot both be 1, by doing this the list should be 80,000 less

``````                For x As Integer = 2000000 To 9999999
If x.ToString Like "[2-9]*" Then
objWriter.WriteLine(x.ToString("D7"))
End If
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:
try this

For x As Integer = 2000000 To 9999999
If x.ToString Like "[2-9]*"  and x.ToString not Like "[1-9]11*"  Then
objWriter.WriteLine(x.ToString("D7"))
End If
Next
0
Author Commented:
this part has an error

Not like "[1-9]11*" Then
0
Author Commented:
``````                For x As Integer = 2000000 To 9999999
If x.ToString Like "[2-9]*" And x.ToString("D7") Like Not "[1-9]11*" Then
objWriter.WriteLine(x.ToString("D7"))
End If
Next
``````

Conversion from string "[1-9]11*" to type 'Long' is not valid.
0
Commented:
try this

For x As Integer = 2000000 To 9999999
If x.ToString Like "[2-9]*"  and  Not (x.ToString("D7") Like "[1-9]11*")  Then
objWriter.WriteLine(x.ToString("D7"))
End If
Next
0

Experts Exchange Solution brought to you by