Solved

generate numbers

Posted on 2012-04-11
5
253 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
  • 2
  • 2
5 Comments
 
LVL 17

Expert Comment

by:Anuroopsundd
Comment Utility
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
Comment Utility
that code is not working
0
 
LVL 39

Expert Comment

by:appari
Comment Utility
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
Comment Utility
not working either.. getting numbers like
0876352
etc..
0
 
LVL 39

Accepted Solution

by:
appari earned 500 total points
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

728 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now