Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

format number generator

Posted on 2012-04-11
4
Medium Priority
?
302 Views
Last Modified: 2012-04-11
hello,
im using the code bellow to generate 8 million unique numbers but I need to add a feature where the first three digits are NXX and and XX cannot both be 1, by doing this the list should be 80,000 less

                For x As Integer = 2000000 To 9999999
                    If x.ToString Like "[2-9]*" Then
                        objWriter.WriteLine(x.ToString("D7"))
                    End If
                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
4 Comments
 
LVL 39

Expert Comment

by:appari
ID: 37836224
try this

                For x As Integer = 2000000 To 9999999
                    If x.ToString Like "[2-9]*"  and x.ToString not Like "[1-9]11*"  Then
                        objWriter.WriteLine(x.ToString("D7"))
                    End If
                Next
0
 
LVL 1

Author Comment

by:XK8ER
ID: 37836247
this part has an error

Not like "[1-9]11*" Then
0
 
LVL 1

Author Comment

by:XK8ER
ID: 37836265
                For x As Integer = 2000000 To 9999999
                    If x.ToString Like "[2-9]*" And x.ToString("D7") Like Not "[1-9]11*" Then
                        objWriter.WriteLine(x.ToString("D7"))
                    End If
                Next

Open in new window


Conversion from string "[1-9]11*" to type 'Long' is not valid.
0
 
LVL 39

Accepted Solution

by:
appari earned 2000 total points
ID: 37836267
try this

               For x As Integer = 2000000 To 9999999
                    If x.ToString Like "[2-9]*"  and  Not (x.ToString("D7") Like "[1-9]11*")  Then
                        objWriter.WriteLine(x.ToString("D7"))
                    End If
                Next
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

730 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