Solved

generate numbers

Posted on 2012-04-11
5
257 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 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

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…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

691 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