By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,441 Members | 996 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,441 IT Pros & Developers. It's quick & easy.

out of bound error no 35600

100+
P: 143
The line itm.ListSubItems.Item(j).Bold = chkBold.Value is giving me error out of bound i think is bcoz of the size of j variable which is related to remark option.. but dont knw how to remove the error



Private Sub AddBoldItems()
Dim i, j As Integer
Dim itm, origItem As ListItem
lvBold.ListItems.Clear
lvBold.ColumnHeaders.Add 1, , "TermID", 1500
lvBold.ColumnHeaders.Add 2, , "TermName", 2000
lvBold.ColumnHeaders.Add 3, , "Remark", 3500
For i = 1 To lvTerms.ListItems.Count
If lvTerms.ListItems(i).Checked = True Then
If lvTerms.ListItems(i).ListSubItems.Count > 0 Then
For j = 1 To lvTerms.ListItems(i).ListSubItems.Count
Set origItem = lvTerms.ListItems(i)
Set itm = lvBold.ListItems.Add(, , origItem.Text)
itm.SubItems(1) = origItem.SubItems(1)
itm.Bold = True
itm.Bold = chkBold.Value
itm.ListSubItems.Item(j).Bold = chkBold.Value
lvBold.Refresh
Next
End If
End If
Next i
End Sub
Jan 9 '08 #1
Share this Question
Share on Google+
8 Replies


QVeen72
Expert 100+
P: 1,445
Hi,

All ListView/ListBox/Combos have Items Index from 0 to Count-1
Change your Code this way:

For i = 0 To lvTerms.ListItems.Count -1
.
.
For j = 0 To lvTerms.ListItems(i).ListSubItems.Count -1


Regards
Veena
Jan 9 '08 #2

100+
P: 143
Hi...
I did the changes but getting the same error
what other changes i can do to make it work?




Hi,

All ListView/ListBox/Combos have Items Index from 0 to Count-1
Change your Code this way:

For i = 0 To lvTerms.ListItems.Count -1
.
.
For j = 0 To lvTerms.ListItems(i).ListSubItems.Count -1


Regards
Veena
Jan 9 '08 #3

QVeen72
Expert 100+
P: 1,445
Hi,

Change it to :

itm.ListSubItems.Item(1).Bold = chkBold.Value


Regards
Veena
Jan 9 '08 #4

100+
P: 143
Ok if i do this changes the problem is the remark bark is not adding to the lvBold... coz tht is Item(j) only... and this way my first TermId repeiting 2 times..
the main problem is with tht remark part of my Lvterms which i want to add to the lvbold and not adding... do u have any other solution?
thankx in advance



Hi,

Change it to :

itm.ListSubItems.Item(1).Bold = chkBold.Value


Regards
Veena
Jan 9 '08 #5

QVeen72
Expert 100+
P: 1,445
Hi,

With your logic, itm always has only one subItem. your code doesnot show adding other 2 subitem..
Either add remaining 2 SubItems and use J , or use only 1..

Regards
Veena
Jan 9 '08 #6

100+
P: 143
oK... Thanks alot for ur help... i have changed my code to this and i m getting all the part but in this line itm.SubItems(3) = origItem.SubItems(3) is telling me "invalid property value" .... wht else i can do?



Private Sub AddBoldItems()
Dim i, j As Integer
Dim itm, origItem As ListItem
lvBold.ListItems.Clear
lvBold.ColumnHeaders.Add 1, , "TermID", 1500
lvBold.ColumnHeaders.Add 2, , "TermName", 2000
lvBold.ColumnHeaders.Add 3, , "Remark", 3500
For i = 1 To lvTerms.ListItems.Count
If lvTerms.ListItems(i).Checked = True Then
If lvTerms.ListItems(i).ListSubItems.Count > 0 Then
For j = 1 To lvTerms.ListItems(i).ListSubItems.Count
Set origItem = lvTerms.ListItems(i)
Set itm = lvBold.ListItems.Add(, , origItem.Text)
itm.SubItems(1) = origItem.SubItems(1)
itm.SubItems(2) = origItem.SubItems(2)
itm.SubItems(3) = origItem.SubItems(3)
itm.Bold = True
itm.Bold = chkBold.Value
itm.ListSubItems.Item(3).Bold = chkBold.Value
lvBold.Refresh
Next
End If
End If
Next i
End Sub
Jan 9 '08 #7

QVeen72
Expert 100+
P: 1,445
Hi,

Try this code:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub AddBoldItems()
  3. Dim i, j As Integer
  4. Dim itm, origItem As ListItem
  5.     lvBold.ListItems.Clear
  6.     lvBold.ColumnHeaders.Add 1, , "TermID", 1500
  7.     lvBold.ColumnHeaders.Add 2, , "TermName", 2000
  8.     lvBold.ColumnHeaders.Add 3, , "Remark", 3500
  9.     For i = 1 To lvTerms.ListItems.Count
  10.         If lvTerms.ListItems(i).Checked = True Then
  11.         If lvTerms.ListItems(i).ListSubItems.Count > 0 Then
  12.             Set origItem = lvTerms.ListItems(i)
  13.             Set itm = lvBold.ListItems.Add(, , origItem.Text)
  14.             For j = 1 To lvTerms.ListItems(i).ListSubItems.Count -1
  15.                 itm.SubItems(j) = origItem.SubItems(j)
  16.                 itm.Bold = chkBold.Value
  17.             Next
  18.             itm.ListSubItems.Item(3).Bold = chkBold.Value
  19.             lvBold.Refresh
  20.         End If
  21.      End If
  22.      Next i
  23. End Sub
Regards
Veena
Jan 9 '08 #8

100+
P: 143
Thanks u very much ...
Jan 9 '08 #9

Post your reply

Sign in to post your reply or Sign up for a free account.