hexagon logo

Need help with VB6 .Net

Upgraded my workstation to Windows 10, so VB6 is no longer an option for my PC-DMIS software efforts.

I've got Visual Studio 2107 now, and I've run into a problem using PC-DMIS collections. In a nutshell, vb6 .net doesn't recognize them as collections. I have to declare the PC-DMIS application as "Object" in order to be able to enumerate through the collections. I was told that this means it's doing "late binding" - who cares. I need intellisense because I'm a terrible typist. In the screenshot below, if I change the declaration of the "app" variable to type "Object", the compile error goes away, and the code runs fine. But I don't see this as a solution.

I'll also point out that the Microsoft's File System Object collections work just fine when used in the same manner.

Has anyone got the solution to this problem?


  • Made me look in mine. Doesn't work. Check mine out..

    Dim app As PCDLRN.Application
    Dim cmds As Object
    Dim cmd As PCDLRN.Command
    Dim part As PCDLRN.PartProgram
    

    Then go ahead and use this
    For Each cmd In cmds
    


    Intellisense pops up with '.Commands' but bombs out during execution yet it's OK with".Command". Weird.
  • Made me look in mine. Doesn't work. Check mine out..

    Dim app As PCDLRN.Application
    Dim cmds As Object
    Dim cmd As PCDLRN.Command
    Dim part As PCDLRN.PartProgram
    

    Then go ahead and use this
    For Each cmd In cmds
    


    Intellisense pops up with '.Commands' but bombs out during execution yet it's OK with".Command". Weird.


    It's the exact same problem I'm having, you're just getting there a different route. You've got cmds declared as Object, when it should be declared PCDLRN.Commands. I've got a bad feeling that this is a problem with the way all of the pc-dmis collections are setup. Hoping like crazy that I'm wrong, and there's just something that I don't know.


  • It's the exact same problem I'm having, you're just getting there a different route. You've got cmds declared as Object, when it should be declared PCDLRN.Commands. I've got a bad feeling that this is a problem with the way all of the pc-dmis collections are setup. Hoping like crazy that I'm wrong, and there's just something that I don't know.


    Hate to say it but I didn't have much time to look into it therefore I didn't have time to get it done 'right'. It worked and I moved on with the intent to go back to solve it, totally forgot about it and it's been in production for about 1.5yrs without an issue. You can even see me scrambling thru code that works based on my comments haha....

    Original snippet:
    Dim app As PCDLRN.Application 'PCDLRN.Application
    Dim cmds As Object 'PCDLRN.Commands
    Dim cmd As PCDLRN.Command 'PCDLRN.Command
    Dim part As PCDLRN.PartProgram 'PCDLRN.PartProgram
    'Dim parts As PCDLRN.PartPrograms 'PCDLRN.PartPograms
    Dim s As String = "" 'string to hold dimensions ID
    Dim r As Integer = 1 'row
    


  • Hate to say it but I didn't have much time to look into it therefore I didn't have time to get it done 'right'.


    Oh, I didn't mean to imply that you did anything wrong. You found the solution and moved on. I did the same thing today. We've both got "real work" to do.

    Hopefully will find this soon and show us that everything is just fine, and all we needed to do was read the help file. Slight smile


  • Oh, I didn't mean to imply that you did anything wrong. You found the solution and moved on. I did the same thing today. We've both got "real work" to do.

    Hopefully will find this soon and show us that everything is just fine, and all we needed to do was read the help file. Slight smile


    The damage is done... I will spend my 4th sad and depressed ^sigh. JK! I was more like thinking out loud. There's no shame in my game !!!

    I bet/hope has a solution too.


  • The damage is done... I will spend my 4th sad and depressed ^sigh. JK! I was more like thinking out loud. There's no shame in my game !!!

    I bet/hope has a solution too.


    Ha! Well, when I came back to see your latest reply, I noticed my BIG GOOF in the thread title. VB 6 .NET? Yeesh... Don't see a way to edit my own post title either...
    Happy 4th to you.
  • Unfortunately I haven't done *any* work in VB.NET (I use the superb Delphi (Pascal) environment when not programming PC-DMIS Basic, Excel or other exotic languages). Actually, I haven't done anything .NET...

    I believe a collection must implement a certain interface/iterator to have "for each" to work - it looks like PC-DMIS is not doing it (or exporting it) in exactly the right way.

    In theory, it looks like you should be able to write an iterator in VB - https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/for-each-next-statement might give some clues for a workaround.
  • Doesn't work - I've not done much with vb.net for a while so looked in an old project.

    Use this instead...


    
    Dim cmds As PCDLRN.Commands = part.Commands
    Dim cmd As PCDLRN.Command
    
    For i = 1 To cmds.Count
    cmd = cmds.Item(i)
    Next i
    
    
  • Bummer.

    Thanks for the tip about the iterator, I was looking at documentation on this myself.

    My main want is to easily convert all of my code that is used in production. Looks like that isn't going to be possible. I'll have to do some re-coding, which opens up the opportunity for error. Oh well, I've been ignoring this VB6 obsolescence topic for many years, so it's largely my fault. It's going to take more time than I'd like to spend.

    You've stated previously here that you use Pascal. I used to have a Borland Turbo Pascal compiler many years ago. Back in the day befire the fancy IDE's. I liked the language - but haven't used it in decades.
  • Yup, there are alternatives. I think for my "serious stuff" that we use in production though, just changing the variable declaration(s) to "Object" is going to be the quickest/safest way. And these are .exe's - there's a slight chance that I'll never need to make changes to the code. But of course right now, I have on that's got to be updated. Haven't touched this code in years, and then a couple weeks after I get Windows 10...