Results 1 to 10 of 10

Thread: Runtime Error 91

  1. #1

    Thread Starter
    Addicted Member Tommy101's Avatar
    Join Date
    Jun 2004
    Location
    Switzerland
    Posts
    144

    Runtime Error 91

    VB Code:
    1. Function ShowDlg(ListView As ListView, ByVal Title As String) As Boolean
    2.     LVExporter.ListView = ListView
    3.    
    4.     Dim selCount As Long, i As Long
    5.     'Determine count of selected entries
    6.     For i = 1 To ListView.ListItems.Count
    7.         If ListView.ListItems(i).Selected Then selCount = selCount + 1
    8.     Next i

    Error Message: Runtime Error 91, Object Vairable or With Block Variable not Set.

    When ever i run this code in another Poject than mine it works fine.

    *The Code is in a ActiveX Control.

    Can anyone give me some ideas of how the Code should be?

  2. #2
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918
    I don't know if this has anything to do with your problem, but possibly because you're using an object type as a variable name, ie ListView As ListView, VB is somehow getting confused. Try this:
    VB Code:
    1. Function ShowDlg([b]MyListView[/b] As ListView, ByVal Title As String) As Boolean
    Change all your references to MyListView. Just a guess
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  3. #3

    Thread Starter
    Addicted Member Tommy101's Avatar
    Join Date
    Jun 2004
    Location
    Switzerland
    Posts
    144
    It still gives me the same Error.

  4. #4
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697
    Which line does the error occur on?

  5. #5

    Thread Starter
    Addicted Member Tommy101's Avatar
    Join Date
    Jun 2004
    Location
    Switzerland
    Posts
    144
    VB Code:
    1. For i = 1 To ListView.ListItems.Count

    That one

  6. #6
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918
    Perhaps you need to do this:
    VB Code:
    1. [b]Set[/b] LVExporter.ListView = ListView
    And also you need to change this line:
    VB Code:
    1. For i = [b]0[/b] To ListView.ListItems.Count [b]-1[/b]
    EDIT: Ignore the first bit of code, that's got nothing to do with it. Sorry.
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  7. #7

    Thread Starter
    Addicted Member Tommy101's Avatar
    Join Date
    Jun 2004
    Location
    Switzerland
    Posts
    144
    It still gives me the stupid Runtime Error 91

  8. #8
    Member
    Join Date
    Oct 2004
    Posts
    43
    Currently I am working on listboxes myself. I am no wizzy about listboxes or ActiveX controls, I ain't even sure your dealing with a listbox.

    VB Code:
    1. For i = 1 To ListView.ListItems.ListCount

    Maybe that works, best wishes Forge.

  9. #9

    Thread Starter
    Addicted Member Tommy101's Avatar
    Join Date
    Jun 2004
    Location
    Switzerland
    Posts
    144
    In a ListView you can not use ListCount only Count, but thanks for your help

  10. #10
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    Show the code that calls this function. The problem lies there.

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