none
VBA to VB.NET conversion RRS feed

  • Question

  • Hi every body !

    i have some of VBA Codes (Access Modules) and i want to convert these VBA codes to VB.NET ?!

    any suggestions !! to solve this problem !!

    must i make a VBA to VB.NET compiler from scratch !!! this problem faced me and i'm looking forward to solve it !!

    thank's in advance

    Thursday, May 13, 2010 7:42 PM

All replies

  • Hi, VBA is a completely different language to .NET ...well sort of... a VBA to VB.NET translator would be a lot of work; a massive undertaking that it would be quicker re-writing the VBA code in VB.NET.\

    Now now now... VB.NET is a bit backwards compatible with VB (and VBA is a subset of VB) so depending on the code and your luck you might get away with it BUT you won't win any best code prizes.... 

    Post an example of the code that needs to be converted and lets see what might be involved. Does the code access the database tables? ADO or DAO?

    Thursday, May 13, 2010 8:40 PM
  •  

    You may have more chance to win the lottery and retire tomorrow and dont have to do this anymore than being compatible

    Thursday, May 13, 2010 9:02 PM
  • thank's for you Derek & Crazypennie for your help ,

    i know that VBA differ than VB.NET .. let me to explain my problem clearly :

    i have an access project and want to convert this project to .NET Solution ! ... i made the conversion of access forms to .NET Forms ... now i should to convert All VBA codes in Modules and Class modules (Forms event handlers) to VB.NET to be running under .NET framework ... till now i can't find a solution to convert VBA Code --> VB.NET and add it as a VB class library on .NET solution ! and i didn't want to make an VBA to VB.NET compiler from scratch :S ! 

    it's not a 1 or 2 VBA Code ! it's a lot of VBA codes as i mentioned above ! so it is difficult to handle all VBA Code cases !! and i don't have time to make a Full compiler !

    sure it has a DAO DB access ..

    i hope my problem to be clear now ! and i'm ready for any clarifications ..

    your friend ... Waleed

    Thursday, May 13, 2010 9:14 PM
  • Waleed, the fact you have a lot of code reduces your chances; it's going to be a lot of work. Crazypennies no nonsense reply might be reasonably accurate but in all fairness people do win the lottery it just might take them lots of time and lots of money ... got to stay positive and not give up before starting. Although it's less than ideal your .NET solution might use a lot of 'legacy' COM objects as that is how VBA works... it's all COM.

    Why the change? I mean if it works in VBA why change to .NET?

    If it was me it would be a complete rewrite and I wouldn't do that unless it was absolutely necessary.

    Tell you what try it out. I mean copy a single function / sub across from VBA to VB.NET and see what's involved in fixing the compile errors. Try that for a morning/afternoon and get a feel for the kind of work involved and how long it might take.I have no idea of the code you have so that's the best I can offer.

    Thursday, May 13, 2010 9:54 PM
  •  

    To me, the only way to get this working without rewriting every thing in VB.NET, would be to keep Access running the existing VBA code in the background and just create a VB.NET user interface. Access can be automated

    I am not saying that it is impossible to create in VB.NET a VBA interpreter, it is sure possible, but I cannot see how this would be less work than rewriting everything.

    It might be some existing commercial VBA interpreter , ... I don't know

    What do you think Derek?

    Thursday, May 13, 2010 10:12 PM
  • Why the change? I mean if it works in VBA why change to .NET?


    i hope that it will be a solution .., ok i won't convert it ... what about these COMs that will execute VBA codes ?

    • Proposed as answer by EuderAlves Sunday, December 9, 2012 3:39 PM
    Thursday, May 13, 2010 10:27 PM
  •  

    To me, the only way to get this working without rewriting every thing in VB.NET, would be to keep Access running the existing VBA code in the background and just create a VB.NET user interface. Access can be automated

    no.., i want to create a standalone .NET solution without using Access Project again !

    Note : i will convert Access DB to SQL server DB and no need for Access Project

    • Proposed as answer by EuderAlves Sunday, December 9, 2012 3:39 PM
    Thursday, May 13, 2010 10:30 PM
  • Hi Waleed,

    I agree with previous answers, we could not make us of the VBA code in VB.Net, as this is a totally different platform. I think you'll have to re-write the code in VB.Net.

    Thanks.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Proposed as answer by EuderAlves Sunday, December 9, 2012 3:39 PM
    Monday, May 17, 2010 9:18 AM