Solved

format number generator

Posted on 2012-04-11
4
292 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
  • 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 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
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.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

929 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

10 Experts available now in Live!

Get 1:1 Help Now