Solved

# generate numbers

Posted on 2012-04-11
254 Views
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
0
Question by:XK8ER
• 2
• 2

LVL 17

Expert Comment

ID: 37836166
if x>=2 and x<=9
then
For x = 1 To 9999999
Debug.Print(x.ToString("D7"))
Next
Else
Error..
End If
0

LVL 1

Author Comment

ID: 37836177
that code is not working
0

LVL 39

Expert Comment

ID: 37836180
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

LVL 1

Author Comment

ID: 37836184
not working either.. getting numbers like
0876352
etc..
0

LVL 39

Accepted Solution

appari earned 500 total points
ID: 37836194
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

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

### Suggested Solutions

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

#### 777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.