?
Solved

generate numbers

Posted on 2012-04-11
5
Medium Priority
?
258 Views
Last Modified: 2012-06-21
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

Open in new window

0
Comment
Question by:XK8ER
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 17

Expert Comment

by:Anuroopsundd
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

by:XK8ER
ID: 37836177
that code is not working
0
 
LVL 39

Expert Comment

by:appari
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

by:XK8ER
ID: 37836184
not working either.. getting numbers like
0876352
etc..
0
 
LVL 39

Accepted Solution

by:
appari earned 2000 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

Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

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

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

Join & Ask a Question