Solved

generate numbers

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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…

733 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