Solved

format number generator

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

751 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