Jump to content

can I access a VB6 control?


dbroada

Recommended Posts

I'm not really sure how to phrase the question so here is my "problem".

 

I have a batch plot builder written in VB6. The main area of interest for now is a list box where the name of files to be printed is stored.

 

What I want to do is have a VB.Net command that will add the current drawing to the VB6 list box.

 

I can determine if the VB6 prog is running (already tested that bit) but is it possible to expose the list box? And if it is possible, any idea what I need to do to get there?

 

I can change the VB6 prog if needed.

Link to comment
Share on other sites

  • Replies 23
  • Created
  • Last Reply

Top Posters In This Topic

  • BlackBox

    10

  • dbroada

    7

  • Tyke

    7

Top Posters In This Topic

Posted Images

I had a similar problem a while ago. I have a small program written a long time ago in VB6 that I wanted to modify, but I don't have VB6 and I don't even know if you can buy it anymore. So I migrated my VB6 code to .NET and had to replace the VB6 list box control with one from .NET because .NET didn't ecognize it. I never managed to solve the VB6 controls problem, but it would be nice to know if a solution exists.

 

It could well be .NET will no write to your VB6 list box.

Link to comment
Share on other sites

the problem at the moment is that I don't really know how to grab the form, let alone the list box.

 

I do have a way for now though. The VB6 prog can load from a file so I can build that in VB.Net and pass the information in that way. I just thought it would be more fun to have the list built within the VB6 bit.

Link to comment
Share on other sites

.NET interacting with a running VB6 program :shock: I've never tried that one Dave and I don't ever recall reading about it either. Come BB tell us what you know.

Link to comment
Share on other sites

... Come BB tell us what you know.

 

Too funny... I just saw this after my last post. :rofl:

 

You already know I skipped VBA as a result of all the Autodesk hype, and even Sr. CAD staff here encouraging me to look to .NET instead... I'm afraid I have very little VBA-centric knowledge, but I can Google like a nobody's business. :geek:

Link to comment
Share on other sites

Also, I forget if you've already been turned onto this (it's an older post from July 2011)... never used it myself, as I skipped VBA, but thought I'd reiterate in case it is of use to you now:

 

You need to use Autodesk's "Magic Macro" to port your VBA code to VB.NET for Visual Studio 2008, then you can open your Visual Studio 2008 project with Visual Studio 2010, and your code will automagically be converted to the current standard, syntax, etc..

 

Just be sure that you set your "compile" .NET Framework to 3.5 (or older) to suit the platforms for which you are writing code.

 

You can still obtain the Express (Free) versions of Visual Studio 2008, and 2010... I personally use 2010. If you go the Express route, there are some tricks to getting it (VSE) to properly debug, and step through breakpoints, etc.

 

Hope this helps!

Link to comment
Share on other sites

Something like this should seemingly work (untested):

 

namespace CADTutor.Sample.Forms
{
   public partial class Form1 : Form
   {
       public ListBox ListBoxControl
       {
           get { return this.listBox1; }
       }
   }

   public class Commands
   {
       [CommandMethod("FOO", CommandFlags.Modal)]
       public void FOO()
       {
           using (Form1 myForm = new Form1())
           {
               string dwgName =
                   (string)Application.GetSystemVariable("DWGNAME");

               myForm.ListBoxControl.Items.Add(dwgName);

               //<-- show your form, or do other work here
           }
       }
   }
}

 

 

Also, FWIW, you could always port your VB6 code to incorporate a Windows Presentation Foundation (WPF) User Control, hosted in an AutoCAD Tool Palette as Kean shows here.

ts_wpfp.sample.awesome.tab.jpg

ts_wpfp.sample.developer.tab.jpg

Link to comment
Share on other sites

Also, I forget if you've already been turned onto this (it's an older post from July 2011)... never used it myself, as I skipped VBA, but thought I'd reiterate in case it is of use to you now:
I did rty that but I knew too little to understand what was going on. Since using the Gerry Winter book I know a lot more and might go back to the magic macro - or maybe not as my VBA code isn't that well written. (Bit like my VB.Net code actually)
Link to comment
Share on other sites

I think what Dave meant by

VB6
is Visual Basic 6 not Visual Basic for Applications 6 (VBA6) and VB6 was the forerunner to VB.NET. Correct me if I am wrong Dave.

 

As I said in post #4 the problem is to get your own .NET application to write to a form an a seperately running program. Writing to form in your own .NET application is a doddle and Dave does that in his VB6 programm. Perhaps I'm missing the point here, but I see what Dave wants to as not being a trivial task.

Link to comment
Share on other sites

Thanks Tyke, that is correct.

 

I don't have enough hours available to spend much time on this so I will be using a text file to transfer the infomation and take the odd look at this when the work gets slack(!).

Link to comment
Share on other sites

I think what Dave meant by is Visual Basic 6 not Visual Basic for Applications 6 (VBA6) and VB6 was the forerunner to VB.NET. Correct me if I am wrong Dave.

 

As I said in post #4 the problem is to get your own .NET application to write to a form an a seperately running program. Writing to form in your own .NET application is a doddle and Dave does that in his VB6 programm. Perhaps I'm missing the point here, but I see what Dave wants to as not being a trivial task.

 

Apologies for the tangent... My last post built on the 'Magic Macro' premise (porting his VBA code to VB.NET), hence the supplementary tangential comments... Feel free to disregard, as they were posted under 'I don't do much Form work' and 'FWIW' context.

Link to comment
Share on other sites

Always happy to not help :beer:

 

no worries BB. If you hadn't joined in Tyke and I would have been discussing what we are doing at Ostern.

 

Das ist gut, es ist fast hier... Frohe Ostern! :beer:

 

That's good, it's almost here ... Happy Easter!

Edited by BlackBox
Added English translation
Link to comment
Share on other sites

I'm good at not helping, and Frohe Ostern to you too.

 

Große Geister, mein Freund, große Geister :lol: ... Und ich danke Ihnen herzlich. :)

 

Great minds, my friend, great minds... And thank you kindly.

Edited by BlackBox
Added English translation
Link to comment
Share on other sites

Now then you two, let's not get carried away, and the German lessons will only take place over a couple of beers :beer::beer:. It's my round in my pub. But come to think of it Dave still owes me one :D

 

Another thing, there is a rule here about only posting in English and we don't want any mods getting angry, do we.

Link to comment
Share on other sites

Now then you two, let's not get carried away, and the German lessons will only take place over a couple of beers :beer::beer:. It's my round in my pub. But come to think of it Dave still owes me one :D

 

*Puts down Google Translate* So... What pub are we going to? :)

 

You know... When I come to your side of the pond. :lol:

 

Another thing, there is a rule here about only posting in English and we don't want any mods getting angry, do we.

 

Thanks for the reminder... English translations added to my prior posts. :thumbsup:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...