Solved

format number generator

Posted on 2012-04-11
4
291 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

760 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

20 Experts available now in Live!

Get 1:1 Help Now