Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 305
  • Last Modified:

format number generator

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
XK8ER
Asked:
XK8ER
  • 2
  • 2
1 Solution
 
appariCommented:
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
 
XK8ERAuthor Commented:
this part has an error

Not like "[1-9]11*" Then
0
 
XK8ERAuthor Commented:
                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
 
appariCommented:
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now