I need to display a 4 character keycode sequence in a textbox... each postion should start with 0 to 0 then A to Z. For example..
0001
0002
0003
0004
0005
0006
0007
0008
0009
000A
000B
|
|
000Z
0010
0011
and so on...
I created some code and it is cycling through ok until the third character get to the letters and then the fourth character letters are skipped. I see the flaw in the control structure, but I can't figure out a way to get around it... Please Help!!!
Here is my code..
Private Sub Command0_Click()
Dim FirstDigit As Integer
Dim SecondDigit As Integer
Dim ThirdDigit As Integer
Dim FourthDigit As Integer
Dim FirstDigit2 As Integer
Dim SecondDigit2 As Integer
Dim ThirdDigit2 As Integer
Dim FourthDigit2 As Integer
Dim FirstLetter As String
Dim SecondLetter As String
Dim ThirdLetter As String
Dim FourthLetter As String
Dim flag As Boolean
flag = False
Dim Keycode As String
Dim z As Long
For FirstDigit = 0 To 9
For SecondDigit = 0 To 9
For ThirdDigit = 0 To 9
For FourthDigit = 0 To 9
If FourthDigit = 9 Then
For FourthDigit2 = 1 To 26
FourthLetter = Choose(FourthDigit2, "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
Me.txtKeycodes.SetFocus
Me.txtKeycodes.Text = FirstDigit & SecondDigit & IIf(ThirdDigit = 10, ThirdLetter, ThirdDigit) & FourthLetter
For z = 0 To 500000
Next z
Next FourthDigit2
Else
Me.txtKeycodes.SetFocus
Me.txtKeycodes.Text = FirstDigit & SecondDigit & ThirdDigit & FourthDigit
For z = 0 To 10000000
Next z
End If
Next FourthDigit
If ThirdDigit = 9 Then 'after textbox displays the 9 for the third digit then test
For ThirdDigit2 = 1 To 26 'takes care of third position letters
ThirdLetter = Choose(ThirdDigit2, "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
For z = 0 To 1000
Next z
Me.txtKeycodes.SetFocus 'needs to cycle in here (with this existing code) the fourth place character
Me.txtKeycodes.Text = FirstDigit & SecondDigit & IIf(ThirdDigit = 9, ThirdLetter, ThirdDigit) & FourthLetter 'works
Next ThirdDigit2
Else
Me.txtKeycodes.SetFocus
Me.txtKeycodes.Text = FirstDigit & SecondDigit & ThirdDigit & FourthDigit
For z = 0 To 10000000
Next z
End If
Next ThirdDigit
Next SecondDigit
Next FirstDigit
End Sub
0001
0002
0003
0004
0005
0006
0007
0008
0009
000A
000B
|
|
000Z
0010
0011
and so on...
I created some code and it is cycling through ok until the third character get to the letters and then the fourth character letters are skipped. I see the flaw in the control structure, but I can't figure out a way to get around it... Please Help!!!
Here is my code..
Private Sub Command0_Click()
Dim FirstDigit As Integer
Dim SecondDigit As Integer
Dim ThirdDigit As Integer
Dim FourthDigit As Integer
Dim FirstDigit2 As Integer
Dim SecondDigit2 As Integer
Dim ThirdDigit2 As Integer
Dim FourthDigit2 As Integer
Dim FirstLetter As String
Dim SecondLetter As String
Dim ThirdLetter As String
Dim FourthLetter As String
Dim flag As Boolean
flag = False
Dim Keycode As String
Dim z As Long
For FirstDigit = 0 To 9
For SecondDigit = 0 To 9
For ThirdDigit = 0 To 9
For FourthDigit = 0 To 9
If FourthDigit = 9 Then
For FourthDigit2 = 1 To 26
FourthLetter = Choose(FourthDigit2, "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
Me.txtKeycodes.SetFocus
Me.txtKeycodes.Text = FirstDigit & SecondDigit & IIf(ThirdDigit = 10, ThirdLetter, ThirdDigit) & FourthLetter
For z = 0 To 500000
Next z
Next FourthDigit2
Else
Me.txtKeycodes.SetFocus
Me.txtKeycodes.Text = FirstDigit & SecondDigit & ThirdDigit & FourthDigit
For z = 0 To 10000000
Next z
End If
Next FourthDigit
If ThirdDigit = 9 Then 'after textbox displays the 9 for the third digit then test
For ThirdDigit2 = 1 To 26 'takes care of third position letters
ThirdLetter = Choose(ThirdDigit2, "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
For z = 0 To 1000
Next z
Me.txtKeycodes.SetFocus 'needs to cycle in here (with this existing code) the fourth place character
Me.txtKeycodes.Text = FirstDigit & SecondDigit & IIf(ThirdDigit = 9, ThirdLetter, ThirdDigit) & FourthLetter 'works
Next ThirdDigit2
Else
Me.txtKeycodes.SetFocus
Me.txtKeycodes.Text = FirstDigit & SecondDigit & ThirdDigit & FourthDigit
For z = 0 To 10000000
Next z
End If
Next ThirdDigit
Next SecondDigit
Next FirstDigit
End Sub