Results 1 to 6 of 6

Thread: Listview(small error)

  1. #1

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Listview(small error)

    For the life of me..i cannot figure this out.

    VB Code:
    1. intItemCount = Form1.ListView.ListItems.Count
    2.                   For a = 1 To intItemCount
    3.                                WhoMsg = GetText(Form1.List1.List(a - 1))
    4.                                Umsg = Split(WhoMsg, ":")
    5.                                TuMsg = Umsg(0)
    6.                     If InStr(Form1.ListView.ListItems.Item(a).Text, TuMsg) Then
    7.                         Form1.ListView.ListItems.Item(1).ListSubItems.Item(a).Text = Form1.ListView.ListItems.Item(1).ListSubItems.Item(a).Text + 1
    8.                     End If
    9.                   Next a

    This bit of code, checks to see the listview item contains the classname (which TuMsg is). It works the first time around (and adds 1) but after that this: Form1.ListView.ListItems.Item(1).ListSubItems.Item(a).Text: gives me an index out of bounds error (there are 2 items)

    I hope you understood, and i hope this is real easy

  2. #2

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Listview(small error)

    seriously..know one knows? Its simple, i know it is.

    edit**figured it out.
    had the a and the 1 backwards
    Last edited by |2eM!x; Jun 29th, 2005 at 11:47 PM.

  3. #3

  4. #4

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Listview(small error)

    yes, and it would say index out of bounds. thats why i posted...

  5. #5
    Addicted Member Bregalad's Avatar
    Join Date
    Jul 2000
    Location
    Oslo,Norway
    Posts
    183

    Re: Listview(small error)

    You are looping through the ListItems with the a variable,
    but using a to select SubItems (Columns) in the loop:

    Form1.ListView.ListItems.Item(1).ListSubItems.Item(a).Text

    To loop through the main ListItems you need to use the "a"
    in the ListItems part. If you have less columnheaders than you
    have listitems the way your code is, it will crash.

    Should it be:
    Form1.ListView.ListItems.Item(a).ListSubItems.Item(1).Text
    or
    Form1.ListView.ListItems(a).Text
    ?

  6. #6
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Listview(small error)

    Quote Originally Posted by |2eM!x
    yes, and it would say index out of bounds. thats why i posted...
    Debugging is not simply running the program until you get an error message, but rather it is the process of setting breakpoints and/or watches to help determine why the error message is displayed.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width