|
-
Mar 23rd, 2009, 06:16 PM
#1
Thread Starter
Hyperactive Member
[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
Last edited by Tamgovb; Mar 24th, 2009 at 04:02 PM.
I know, I know, my English is bad, sorry .....
-
Mar 23rd, 2009, 06:24 PM
#2
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.
_____________________________________________________________________
----If this post has helped you. Please take time to Rate it.
----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.

-
Mar 24th, 2009, 04:11 PM
#3
Thread Starter
Hyperactive Member
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 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
Last edited by Tamgovb; Mar 24th, 2009 at 04:25 PM.
I know, I know, my English is bad, sorry .....
-
Mar 24th, 2009, 04:59 PM
#4
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
-
Mar 24th, 2009, 06:08 PM
#5
Thread Starter
Hyperactive Member
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
I know, I know, my English is bad, sorry .....
-
Mar 24th, 2009, 06:12 PM
#6
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
_____________________________________________________________________
----If this post has helped you. Please take time to Rate it.
----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.

-
Mar 24th, 2009, 06:25 PM
#7
Thread Starter
Hyperactive Member
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
|