themanof83
Registered User.
- Local time
- Today, 01:54
- Joined
- May 1, 2008
- Messages
- 73
Ok,
I'm again at my wits end... I really don't understand why the following code isn't looping through correctly. The code is to pull out a string (path) for each element in the variables array. Then for each element in the three arrays, write the string to the given file i.e. elements 0 first from each array, then elements 1 from each array, then elements 2... etc.
I know that the writing to file part is perfect as it's something I've used a million times. What is seemingly happening is that the code is looping through each If statement individually and incrementing the element number within the If statement, rather than looping through all the If statements for one element then incrementing the element number and looping through the code again.
So instead of getting the first elements from the three arrays I am getting each element from the first array then each element from the second array etc.....
I would very much appreciate your help guys, surely I'm doing something stupid!!
Cheers!
I'm again at my wits end... I really don't understand why the following code isn't looping through correctly. The code is to pull out a string (path) for each element in the variables array. Then for each element in the three arrays, write the string to the given file i.e. elements 0 first from each array, then elements 1 from each array, then elements 2... etc.
I know that the writing to file part is perfect as it's something I've used a million times. What is seemingly happening is that the code is looping through each If statement individually and incrementing the element number within the If statement, rather than looping through all the If statements for one element then incrementing the element number and looping through the code again.
So instead of getting the first elements from the three arrays I am getting each element from the first array then each element from the second array etc.....
I would very much appreciate your help guys, surely I'm doing something stupid!!
Code:
For introw = 0 To 20
'Debug.Print CustomCount
If CustomCount = 0 Then
'Default to A
FileSet = "A"
Chk(introw) = False
ElseIf CustomCount = CustomMax Then
'Reset Counter and Increment Set Letter
CustomCount = 0
FileSet = IncrementTextString(FileSet)
Chk(introw) = False
'Else
'FileSet = IncrementTextString(FileSet)
End If
'Debug.Print FileSet
MyFile = d.Column(2) & d.Column(3) & "\test\AUTOTEST\batch\" & "QTG_" & CustomFile & "_" & FileSet
If Not FileLocked(MyFile) Then
'File Number = current iteration
fnum = FreeFile()
'Open File
Open MyFile For Append As fnum
'Print to File
If (Not (Nz(Path1a(introw), "") = "") And (CustomCount < CustomMax)) Then
Print #fnum, Path1a(introw)
CustomCount = CustomCount + 1
Debug.Print Path1a(introw)
End If
If (Not (Nz(Path1b(introw), "") = "") And (CustomCount < CustomMax)) Then
Print #fnum, Path1b(introw)
CustomCount = CustomCount + 1
Debug.Print Path1b(introw)
End If
If (Not (Nz(Path1c(introw), "") = "") And (CustomCount < CustomMax)) Then
Print #fnum, Path1c(introw)
CustomCount = CustomCount + 1
Debug.Print Path1c(introw)
End If
Else
'Print to File
If (Not (Nz(Path1a(introw), "") = "") And (CustomCount < CustomMax)) Then
Print #fnum, Path1a(introw)
CustomCount = CustomCount + 1
End If
If (Not (Nz(Path1b(introw), "") = "") And (CustomCount < CustomMax)) Then
Print #fnum, Path1b(introw)
CustomCount = CustomCount + 1
End If
If (Not (Nz(Path1c(introw), "") = "") And (CustomCount < CustomMax)) Then
Print #fnum, Path1c(introw)
CustomCount = CustomCount + 1
End If
End If
Close #fnum
Debug.Print introw
Next introw
Cheers!