Visual Basic Listview errors in Acad 2015 (64 bit)

Visual Basic Listview errors in Acad 2015 (64 bit)

craigmetts
Explorer Explorer
1,242 Views
4 Replies
Message 1 of 5

Visual Basic Listview errors in Acad 2015 (64 bit)

craigmetts
Explorer
Explorer

I have a huge prolem with a VBA program, and while I know lisp, I'm a novice with Visual Basic.  The company I work for has a great inhouse program that was written in Visual Basic.  We are now all running 2015 on 64 bit machines and I've been working on upconverting the program with the VBA enbabler.  However, while everything else seems to be correct, I'm getting the error message, "Method or data member not found" for "Listview1". 

After doing some research, it seems that this is a problem under 64 bit.  Is there a way to make this work or else subsitute it for another routine?  Here's a portion of the code:

 


 '----------------------------------------------------------------------------
 '--- populates listview with point data from drawing
 '----------------------------------------------------------------------------
 
   Dim pointblock As AcadBlockReference

   Dim i As Integer
   Dim itmX As ListItem
   Dim itemis As String
   Dim colx As ColumnHeader
  
    '--- clear the listview table
   frm_asurvey.ListView1.ListItems.Clear
   frm_asurvey.ListView1.ColumnHeaders.Clear
  
   'lwidth = frm_asurvey.lst_points.width - 5 * screen.twipsperpixelx
   lwidth = 100
  'Create and populate the listview
  
    Set colx = frm_asurvey.ListView1.ColumnHeaders.Add(, , "Point #", 30)
    Set colx = frm_asurvey.ListView1.ColumnHeaders.Add(, , "Northing", lwidth)
    Set colx = frm_asurvey.ListView1.ColumnHeaders.Add(, , "Easting", lwidth)
    Set colx = frm_asurvey.ListView1.ColumnHeaders.Add(, , "Elevation", 70)
    Set colx = frm_asurvey.ListView1.ColumnHeaders.Add(, , "Description", 200)
    Set colx = frm_asurvey.ListView1.ColumnHeaders.Add(, , "SORTON", 0)
   

0 Likes
1,243 Views
4 Replies
Replies (4)
Message 2 of 5

norman.yuan
Mentor
Mentor

You did not say, but it is very likely the ListView control you are refrerring to is from MSCOMCTL.ocx, which is 32-bit component, as you have already been aware of. If so, then the answer to your question is NO, you cannot make it work in 64-bit VBA.

 

You either need to find a 64-biy replacement of it (unlikely), or use something else, or even port your VBA code to .NET API code. If you at least can do some reasonable VBA, a quick solution, easier and a bit ugly, is to use VBA built-in ListBox and to make it multiple columns, so the listbox would at least look like a the listview (if you use LIstView only with "Detail" view).

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 5

craigmetts
Explorer
Explorer

Thanks Norman,

yes it's coming from MSCOMCTL.ocx and I read somewhere about ListBox being an alternative.  Your reply confirms that.  

 

Is there an example of how to make ListBox with multiple columns?

0 Likes
Message 4 of 5

lando7189
Advocate
Advocate

I encountred a similar issue.  I wound up creating (in 32 bit VBA) a 'myListView' class where one of the properties is a listbox, and then added properties and functions that have the same names as those in a ListView -- that way, i didn't have to change a bunch of code to adapt each occurance of a listview to a list box.  I just had to swap out the listview (lvwSelections) for a listbox (lstSelections), and then in the code for the form, added a global instance of myListView (Public lvwSelections as New myListView) and set my 'grid' property to the listbox (lvwSelections.Grid = lstSelections).  I wound up having to create another half-dozen classes to support ColumnHeader, ListItem, & SubItem -- but it all worked pretty well.

 

When i loaded it into 64 bit AutoCAD, all i had to was some 64bit clean up (PtrSafe declerations, LongPtr, DoEvents before iterating collections, etc).

 

If your interested it, i'll see if i can isolate these to a separate dvb file.

0 Likes
Message 5 of 5

Anonymous
Not applicable

Looking around I found one that made their own functions to implement their own treeview in VBA for 64-bit with alot of functionality to choose from. I havent tested it yet but should work with downloading the excel version and export all classes, form, modules and import them to autocad and try to run it after changing were the data should come from. Have a look here: http://jkp-ads.com/articles/treeview.asp

I hope it works for VBA 7.1 as well. I will probably have to use this.

0 Likes