VB6 Moving Array Elements into Textbox
Hi all,
I have an array, and I want to copy certain fields of a row and column to a textbox.
The program is to evaluate the 5th column of every row. If the 5th column has a '1', it copies the 1st column of that row to the text box. In other words, if a given row has the elements 7 2 3 4 1 5, since the 5th element is equal to one, copy the first element of that row to the text box which is 7.
My problem is, it only copies the last instance of column 5 having a 1, and leaves the other rows out. How can I copy all of the instances of this to the text box instead of just the last?
What I have is below.
Code:
For R = 0 To endrows ' Cycle through all rows
If (B(R, C) = "1") Then ' If the 5th column of a row has a 1
Text1.Text = B(R, C) ' then copy the 1 value in that row to the textbox
End If
Next R
Re: VB6 Moving Array Elements into Textbox
Found quick solution. Sorry for wasting the post. All I added was a carriage return then added then incremented the Textbox.
Code:
For R = 0 To endrows
If (B(R, 4) = "1") Then
Text1.Text = B(R, 2) + vbCrLf + Text1.Text
End If
Next R
Re: VB6 Moving Array Elements into Textbox
Glad you resolved it...you should mark this thread as resolved. (Menu, Thread Tools).
Just curious, why not use a listbox instead of a multiline textbox....would be easier.
Re: VB6 Moving Array Elements into Textbox
not that this is wrong but if you want to add things backwards you got it right
Code:
For R = 0 To endrows
If (B(R, 4) = "1") Then
Text1.Text = B(R, 2) + vbCrLf + Text1.Text
End If
Next R
if you want to add in the right order use this instead
Code:
For R = 0 To endrows
If (B(R, 4) = "1") Then
Text1.Text = Text1.Text & B(R, 2) & vbCrLf
End If
Next R
please do not use a + sign to add strings together, you might get away with it but eventually you might run into some errors use the & sign