|
-
Sep 12th, 2004, 05:33 AM
#1
Thread Starter
Lively Member
Number Generator XXX999
Hi all,
Silly easy question here.
How can I go about generating a number in the format
'AAA000"
AAA001"
...
AAA999
AAB001
...
AAZ999
ABA000vance
...
I need to be able to do this in Access (yuk) and so I cant use any fancy VB functions.
Thanks in Advance
You are living a pacifist dream, and if you dreaming it means you sleeping and you should damn well wake up!
-
Sep 12th, 2004, 08:34 AM
#2
Hyperactive Member
You need to program this in VBA, then?
Obey the dragon thing. Or not. Or possibly just a bit.
-
Sep 12th, 2004, 09:00 AM
#3
Thread Starter
Lively Member
Yep...but I dont mind a solution in VB since im sure the logic would help.
You are living a pacifist dream, and if you dreaming it means you sleeping and you should damn well wake up!
-
Sep 12th, 2004, 10:05 AM
#4
Might not be elegant - but here's a solution:
VB Code:
Private Sub Form_Load()
Dim lngChr1 As Long
Dim lngChr2 As Long
Dim lngChr3 As Long
Dim lngNumber As Long
Dim strText As String
lngChr1 = 1
lngChr2 = 1
lngChr3 = 1
lngNumber = -1
Do
lngNumber = lngNumber + 1
If lngNumber > 999 Then
lngNumber = 0
lngChr3 = lngChr3 + 1
If lngChr3 > 26 Then
lngChr3 = 1
lngChr2 = lngChr2 + 1
End If
If lngChr2 > 26 Then
lngChr2 = 1
lngChr1 = lngChr1 + 1
End If
If lngChr1 > 26 Then Exit Do
End If
strText = Chr$(lngChr1 + 64) & Chr$(lngChr2 + 64) & Chr$(lngChr3 + 64) + Format$(lngNumber, "00#")
Debug.Print strText
Loop
End Sub
-
Sep 12th, 2004, 11:29 AM
#5
Thread Starter
Lively Member
Thanks alot.
I havent been coding for over 3 years now and realise just how lazy and rubbish I have become
You are living a pacifist dream, and if you dreaming it means you sleeping and you should damn well wake up!
-
Sep 12th, 2004, 11:12 PM
#6
Frenzied Member
VB Code:
Dim n As Integer
Dim x As Integer
Dim y As Integer
Dim z As Integer
For x = 65 To 90
For y = 65 To 90
For z = 65 To 90
For n = 0 To 999
Debug.Print Chr$(x) & Chr$(y) & Chr$(z) & Format$(n, "00#")
Next
Next
Next
Next
-
Sep 13th, 2004, 08:59 AM
#7
dis1411 - that is much more elegant than mine
-
Sep 13th, 2004, 01:14 PM
#8
Frenzied Member
-
Sep 13th, 2004, 01:19 PM
#9
Originally posted by dis1411
Did looping come to mind immediately, or did you at least use my code as a jumping point?
-
Sep 13th, 2004, 08:06 PM
#10
Frenzied Member
when i saw number / letter generation like that, nested for..nexts came to mind
i did copy and paste your debug.print line, although i changed it
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|