Results 1 to 11 of 11

Thread: ListView Item Assignment Failing ?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2017
    Posts
    743

    ListView Item Assignment Failing ?

    Believe it or Not this is my first usage of a Listview to "give it a go" instead of using my normal MSFlexgrid.
    As with my MSFlexgrid I want the user to be able to Add/ Edit and Delete subitems on the grid itself.

    I'm still using VB5 instead VB6.

    Anyone see anything wrong with this assignment. The value on the subitem is pickup up correctly just fails with Error 13 - Type MisMatch:

    Code:
    Note:  I also tried declaring local to see if something else was going on.
    
       Private itmClicked As ListItem
       Set itmClicked = ListView1.ListItems.Item(HTI.iItem + 1)  '<< iItem is good.
    
    Also tried:
    Set itmClicked = ListView1.ListItems(HTI.iItem + 1)

  2. #2
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,431

    Re: ListView Item Assignment Failing ?

    I don't immediately see what's wrong.
    I created a small test project

    You need 1 ListView control named ListView1 and a CommandButton named Command1
    Code:
    Option Explicit
    
    Private Sub Form_Load()
      Dim i As Long
      Dim oLI As ListItem
      
      With ListView1
        .View = lvwReport
        .ColumnHeaders.Clear
        .ColumnHeaders.Add , , "Column 1"
        .ColumnHeaders.Add , , "Column 2"
        .ListItems.Clear
        
        For i = 1 To 10
          Set oLI = .ListItems.Add(, , "R" & i & CStr("C1"))
          oLI.SubItems(1) = "R" & CStr(i) & "C2"
        Next i
      End With
    End Sub
    
    
    Private Sub Command1_Click()
      Dim oLI As ComctlLib.ListItem
      
      Set oLI = ListView1.ListItems(3)
      ' Text of main column and the first sub column
      Debug.Print oLI.Text, oLI.SubItems(1)
    End Sub
    When clicking the command button you should the following in the "Immediate" pane:
    R3C1 R3C2

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2017
    Posts
    743

    Re: ListView Item Assignment Failing ?

    Arnoutdv:

    Thanks for all your effort.
    That is what I get with your code, so something else must be going on.

    One other question:
    I noticed in my Project/Reference list I had checked:

    MS Common Controls 6.0 (SP6) which references agRichEdit.ocx.

    To my recollection I never installed this (obviously came from some other program),
    but I don't use a RichEdit control in this project, again as I recall as big project.
    Tried to UNCHECK from both Controls List and References list and error with "IN USE".
    Looked in VBP file to see if I could pinpoint WHERE USED? No Luck.

    Any easy way to ID what Control (assume RichEdit) and What Form in the Project that control resides??
    Want to see if maybe a conflict between VB6 and VB5 that causes the subject issue.

    Forgot to say, I did a code search for "Rich" which found several lines which were REMMED referencing a RichTextBox, BUT no RTB exists on the form. So the Project thinks or includes it, Finding where it is at?
    Last edited by vb6forever; Oct 3rd, 2022 at 09:26 AM.

  4. #4
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,431

    Re: ListView Item Assignment Failing ?

    Check also the references in the forms (*.frm files) with a text editor.
    Maybe there is still a lingering reference somewhere

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2017
    Posts
    743

    Re: ListView Item Assignment Failing ?

    OK:

    Regarding the ListView.
    Problem SOLVED. Thanks for the help.
    HOWEVER, most interesting I had to declare in my program:

    Code:
     Dim oLI As ComctlLib.ListItem                           << YOURS
     Private itmClicked As MSComctlLib.ListItem        << MINE
    ===============================

    So believe on the right track ALSO with the RichTextbox issue.

    Regarding using text editor instead of IDE good idea.

    Still would be most interested WHERE VB is picking up the references to both ComctlLib AND MSComctlLib
    as NOT listed in the VBP. Maybe internally within VB program itself using the Component / Reference checkboxes, WITH
    that being the linkage (display) to let user know it's included ?
    Intra working of VB itself never an area I've taking the time to delve into.
    Last edited by vb6forever; Oct 3rd, 2022 at 10:20 AM.

  6. #6
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    3,611

    Re: ListView Item Assignment Failing ?

    Comctllib is 'Common Control 5.0', Mscomctllib is 'Common Controls 6.0'

    Ironically 5.0 are the more modern ones, because they're dynamically bound to the *current* comctl32.dll, but mscomctl contain a static version from when the control was made. 6.0 exposes more features to native language that are a little difficult to do via API like subitem fonts, but the total feature set accessible by API/COM is far, far less.

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2017
    Posts
    743

    Re: ListView Item Assignment Failing ?

    fafalone: Thanks for the explanation.

    What I'm trying to get my head around right now, is how VB is determining what
    goes into the VBP file and what doesn't.
    For example : This VBP contains:

    Object={BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0; TABCTL32.OCX
    Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\Windows\System32\stdole2.tlb#OLE Automation
    Reference=*\G{00025E01-0000-0000-C000-000000000046}#4.0#0#C:\Program Files\Common Files\Microsoft Shared\DC:\Program Fi#Microsoft DAO 3.51 Object Library
    Object={6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0; comctl32.ocx
    Reference=*\G{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}#1.0#0#C:\Windows\System32\shell32.dll#Microsoft Shell Controls And Automation
    So somehow MS has decided TABCTL32.OCX should be in the VBP, even though it is Checked within the IDE Controls list.
    Another example (question) is logic says comctl32.ocx may contain a reference "internally" to comctllib (??), but if that is the case,
    why is there NOT mscomctl32.ocx which contains a reference to mscomctllib? JUST WONDERING

  8. #8
    PowerPoster
    Join Date
    Feb 2006
    Posts
    23,804

    Re: ListView Item Assignment Failing ?

    The comctl32.dll library is a flat DLL, so comctl32.ocx does not "reference" it in the sense of an ActiveX reference to a typelib embedded within it.

    The mscomctl.ocx is either statically linked to an ancient version of comctl32.lib or else a bunch of its source was imported into the body of the OCX. It doesn't matter which from our point of view. The point is that the code is now cast in stone, unlike comctl32.ocx which uses dynamic linking to a system DLL.

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2017
    Posts
    743

    Re: ListView Item Assignment Failing ?

    dilettante: Thanks, starting to put it mentally together.
    Personally I'd like to see everything at the front end of the VBP so I know what I got.

  10. #10
    PowerPoster
    Join Date
    Feb 2006
    Posts
    23,804

    Re: ListView Item Assignment Failing ?

    As far as I know the "Object" metadata is only added to FRM modules so that if another Project imports the FRM file VB6 knows to copy it into the new Project's VBP file if not already present.

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2017
    Posts
    743

    Re: ListView Item Assignment Failing ?

    dilettante: Make sense. Thanks.

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