[RESOLVED] Trapping of arrays - HELP ME!!!!
Hi All
Here is my prob
I want to trap the array of data - it's condition. Then I want add it to List1.
However I get an error. >> Subscript out of range <<. What it's wrong?
my code:
Code:
Option Explicit
Private Sub Command1_Click()
Dim IntCounter As Integer
Dim strData() As String
For IntCounter = 0 To 4
If txtDana(IntCounter).Text <> "" Then
strData(IntCounter) = lblZwierzaki(IntCounter).Caption ' <<< here I get this error
List1.AddItem strData(IntCounter) ' it was: List1.AddItem Sztuki(IntCounter)
End If ' I correct already this now
Next
End Sub
thanks in advance
Re: Trapping of arrays - HELP ME!!!!
whats txtDana() ? Is that declared outside the scope ?
whats Sztuki() ? Is that also declared outside the scope?
Where are you getting the error ? You have 3 arrays here.. which line is the error in?
You need Redim Preserve strdata(IntCounter) before you actually fill it.
Re: Trapping of arrays - HELP ME!!!!
Hi
thanks for answer.
TxtDana() – it’s the array of objects (5 textboxes)
Sztuki() - it was my mistake, already I correct it - should be:
Code:
List1.AddItem strData(IntCounter)
Please look in my code.
some1uk03 wrote - quote:
>> You need Redim Preserve strdata(IntCounter) before you actually fill it. <<
OK, hmmm:confused: you would can show me in my code?
My idea: Near every txtbox is Label with name. Now, I want write it to the List1, all these name from Labeles this txtbox in which some values were. How to make? Trapping of arrays?
thanks in advance
Re: Trapping of arrays - HELP ME!!!!
strData() cannot be used without a Redim as mentioned in post#2.
However, you don't need strData() to add those captions into Listbox.
Code:
Option Explicit
Private Sub Command1_Click()
Dim IntCounter As Integer
For IntCounter = 0 To 4
If txtDana(IntCounter).Text <> "" Then
List1.AddItem lblZwierzaki(IntCounter).Caption
End If
Next
End Sub
Re: Trapping of arrays - HELP ME!!!!
Hi
anhn thank you, sorry, I knew about this. I need some way to trap the array because in my project I have to write in proper column these data in my ListBox (I use Send Message function to create these columns) The division of data on a columns, way to displays this, it all forces such solution (trapping arrays). This code will be as example only my prob.
Therefore I ask about some an example of code, showing how to trap this array?
Please help me, thanks in advance
Re: Trapping of arrays - HELP ME!!!!
Try:
Code:
Private Sub Command1_Click()
Dim IntCounter As Integer
Dim strData() As String
For IntCounter = 0 To 4
If txtDana(IntCounter).Text <> "" Then
Redim Preserve strData(IntCounter)
strData(IntCounter) = lblZwierzaki(IntCounter).Caption ' <<< here I get this error
List1.AddItem strData(IntCounter) ' it was: List1.AddItem Sztuki(IntCounter)
End If ' I correct already this now
Next
End Sub
Re: Trapping of arrays - HELP ME!!!!
some1uk03, it fine working!!!!!!!!!!!!!!!! :D:thumb::thumb::thumb::thumb:;)
Thanks, many thanks
tamgovb