Solved

generate numbers

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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

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…
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.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

839 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