|
-
Feb 4th, 2008, 07:49 AM
#1
Thread Starter
Interweb adm/o/distrator
[RESOLVED] Ordering of data
Code:
For i = 0 To txtInfo.Count - 1
If Not txtInfo(i) = vbNullString Then
Print #filenum, lblinfo(i) & " " & txtInfo(i)
strbuffer = strbuffer + vbCrLf + lblinfo(i).Caption & " " & txtInfo(i).Text
End If
Next i
For i = 0 To cmbInfo.Count - 1
If Not cmbInfo(i) = vbNullString Then
Print #filenum, lblsm(i) & " " & cmbInfo(i)
strbuffer = strbuffer + vbCrLf + lblsm(i).Caption & " " & cmbInfo(i).Text
End If
Next i
That is the code i am using at the moment to write some stuff to a text file (don't worry to much about strbuffer thats for the clipboard) now what i need is to print the data to the text file but ordered in such a way that cmbinfo(0 and 1) are positioned in the middle of the txtInfo(i) control array.
So the output would be...
txtInfo(0)
txtInfo(1)
txtInfo(2)
txtInfo(3)
txtInfo(4)
cmbInfo(0)
cmbInfo(1)
txtInfo(5)
...
Just to remind you guys i cant add both control arrays together as they aren't identical controls.
Any ideas? I need this as soon as possible! Otherwise i will have to remove the control array and do it a much slower way
-
Feb 4th, 2008, 08:34 AM
#2
Thread Starter
Interweb adm/o/distrator
Re: Ordering of data
Hmm maybe a select case? I am using an if statement at the moment only because it is shorter. But if there is a better way please do tell
-
Feb 4th, 2008, 08:48 AM
#3
Thread Starter
Interweb adm/o/distrator
-
Feb 4th, 2008, 02:49 PM
#4
Re: Ordering of data
Add a Boolean variable, a Select Case, and nest the cmb inf array as follows:
Code:
Dim CmbInf As Boolean
For i = 0 To txtInfo.Count - 1
Select Case i
Case Is < 5
If Not txtInfo(i) = vbNullString Then
Print #filenum, lblinfo(i) & " " & txtInfo(i)
strbuffer = strbuffer + vbCrLf + lblinfo(i).Caption & " " & txtInfo(i).Text
End If
Case Else
If CmbInf = False Then
For j = 0 To cmbInfo.Count - 1
If Not cmbInfo(j) = vbNullString Then
Print #filenum, lblsm(j) & " " & cmbInfo(j)
strbuffer = strbuffer + vbCrLf + lblsm(j).Caption & " " & cmbInfo(j).Text
End If
Next j
CmbInf = True
End If
If Not txtInfo(i) = vbNullString Then
Print #filenum, lblinfo(i) & " " & txtInfo(i)
strbuffer = strbuffer + vbCrLf + lblinfo(i).Caption & " " & txtInfo(i).Text
End If
End Select
Next i
-
Feb 4th, 2008, 07:29 PM
#5
Thread Starter
Interweb adm/o/distrator
Re: Ordering of data
Sorry for the delay fixed it 
Here is what i came up with...
Code:
For i = 0 To txtInfo.Count - 1
If Not txtInfo(i) = vbNullString Then
If i = 3 Then
For j = 0 To cmbInfo.Count - 1
If Not cmbInfo(j) = vbNullString Then
Print #filenum, lblsm(j) & " " & cmbInfo(j)
strbuffer = strbuffer + vbCrLf + lblsm(j).Caption & " " & cmbInfo(j).Text
End If
Next j
End If
Print #filenum, lblinfo(i) & " " & txtInfo(i)
strbuffer = strbuffer + vbCrLf + lblinfo(i).Caption & " " & txtInfo(i).Text
End If
Next i
-
Feb 6th, 2008, 12:32 PM
#6
Re: [RESOLVED] Ordering of data
Good show, Paul. I realize you marked the post resolved, but based on your original order condition for writing the information as shown in Post #1, I think you want "If i = 5 Then" rather than "If i = 3 Then" on the third line.
Just my $0.02.
-
Feb 6th, 2008, 07:43 PM
#7
Thread Starter
Interweb adm/o/distrator
Re: [RESOLVED] Ordering of data
Nah sorry that was just a total example
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
|