473,499 Members | 1,926 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

out of bound error no 35600

143 New Member
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
8 3188
QVeen72
1,445 Recognized Expert Top Contributor
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
squrel
143 New Member
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
1,445 Recognized Expert Top Contributor
Hi,

Change it to :

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


Regards
Veena
Jan 9 '08 #4
squrel
143 New Member
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
1,445 Recognized Expert Top Contributor
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
squrel
143 New Member
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
1,445 Recognized Expert Top Contributor
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
squrel
143 New Member
Thanks u very much ...
Jan 9 '08 #9

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

Similar topics

8
2928
by: Kevin Little | last post by:
#!/usr/bin/env python ''' I want to dynamically add or replace bound methods in a class. I want the modifications to be immediately effective across all instances, whether created before or...
2
3855
by: CSDunn | last post by:
Hello, I have an MS Access 2003 Project form in which I need to set the value of a textbox named 'TestGrade' to the value present after the update of a combo box currently named 'Combo6'. The data...
19
4065
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
14
10099
by: Abhi | last post by:
FYI: This message is for the benefit of MS Access Community. I found that this prblem has been encounterd by many but there is hardly any place where a complete solution is posted. So I thought...
2
2471
by: Igor Shevchenko | last post by:
Hi. I've got a problem with using cursor in a plpgsql function. Cursor is created via DECLARE, it's SELECT query has placeholders. I use PostgreSQL 7.4.2. Here's a problematic plpgsql...
3
4950
by: Furty | last post by:
Hi, I'm looking for the best practice for creating a generic data validation implementation for my data bound business objects. I currently have a business object base class implementing the...
2
4511
by: gmccallum | last post by:
I have a data entry screen using controls bound through a bindingSource, TableAdaptor and a BindingNavigator to move through the records. When I have an data entry error (such as Null for a value)...
1
950
by: Bishop | last post by:
Any ideas on why this is happening or how I can fix it? For instance if I forget to declare a SQL Variable and assign it a value instead of telling me that it redirects to 404 page not found...
1
9284
by: mknoll217 | last post by:
I am recieving this error from my code: The multi-part identifier "PAR.UniqueID" could not be bound. The multi-part identifier "Salary.UniqueID" could not be bound. The multi-part identifier...
0
7134
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7012
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7392
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5479
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4920
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4605
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1429
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
307
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.