Author Topic: VBA to VB  (Read 963 times)

0 Members and 1 Guest are viewing this topic.

robplatt

  • Guest
VBA to VB
« on: February 18, 2007, 04:14:38 AM »
I've been working in VBA to automate interactions between AutoCAD and Access - things I should be able to get from Map or Civil 3D but haven't been able to achieve. Anyway, I like the enhancements you can get from using VB 2005, but I've got lots of stuff in VBA. Does anyone know of a single reference that highlights the differences to assist with moving code from one to the other? Or maybe someone's even written some code that would do most of the work for me (is that wishful thinking?)?

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16727
  • Superior Stupidity at its best
Re: VBA to VB
« Reply #1 on: February 18, 2007, 10:00:41 AM »
I think you will find that most of the VBA code can be ported directly to VB if you export the modules and forms, you can import them into VBA. you will then have to sort through the code and add the required references. There will bo some code tweaks, but the IDE will give you direction on what needs to be done.
Of course the biggest problem is the forms, as the forms and controls in VBA are MSForms2.0 while the VB forms are not. They should still work, but they will be listed ad "Designers" in the IDE and they are more difficult to modify. I generally rebuild all of the forms in VB if I port it over. The code can be simply pasted in the code segment of the forms.

Sorry I don't have a magic bullet .. if you find one, let me know .. I could use one too.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

robplatt

  • Guest
Re: VBA to VB
« Reply #2 on: February 19, 2007, 05:55:44 AM »
Thanks Keith,
That gives me encouragement. From the reading I had done I was expecting some painful work ahead of me!

Dnereb

  • Guest
Re: VBA to VB
« Reply #3 on: February 20, 2007, 05:04:22 AM »
Well.... Sorry to dissapoint you.

VBA and VB.Net do not have anything in common, in but some resamblence in code writing.
VBA isn't based on the .NET framework and code will run in some cases but rarely without serious alteration.
in fact the VB6 converter to .NET from Microsoft will not produce running code most of the times.
VB 6.0 on the other hand  is quite similar to VBa (VBA is a subset of VB6.0)......

BTW: To use an Access Database you need to make a connection to the database, do not open the access application. You can find the connection strings on www.connectionstrings.com.
And code to connect to a Access database can be found on www.VBForums.com (VB6 and .NET)

Good luck on your quest.






robplatt

  • Guest
Re: VBA to VB
« Reply #4 on: February 20, 2007, 05:26:52 AM »
Hi Dnereb,
Well that's put a damper on things! Looks like I'm going to have to start again.
My VBA is working quite well - I was just hoping I could move up a notch with a simple transition.
Thanks for the pointers though.

Dnereb

  • Guest
Re: VBA to VB
« Reply #5 on: February 20, 2007, 07:26:37 AM »
Is using VB6 instead of .NET not an option?

robplatt

  • Guest
Re: VBA to VB
« Reply #6 on: February 21, 2007, 03:37:15 AM »
You are right - it would be worth trying.
I'll keep you posted.