dcsimg
Results 1 to 19 of 19

Thread: Convert VBA and VB6 code to C# or VB.NET?

  1. #1

    Thread Starter
    Addicted Member kutlesh's Avatar
    Join Date
    Jun 2018
    Location
    Skopje, Macedonia
    Posts
    195

    Convert VBA and VB6 code to C# or VB.NET?

    Is there rather painless way to convert old VB6 or Access 2000 VBA code to C# or VB.NET?

    Any tutorials on the topic?

  2. #2
    PowerPoster
    Join Date
    Jun 2013
    Posts
    4,890

    Re: Convert VBA and VB6 code to C# or VB.NET?

    For VB6... no.

    For Access2000-VBA... why not import that into a more recent version of Access?
    (it's still a fully supported MS-product)...

    Olaf

  3. #3

    Thread Starter
    Addicted Member kutlesh's Avatar
    Join Date
    Jun 2018
    Location
    Skopje, Macedonia
    Posts
    195

    Re: Convert VBA and VB6 code to C# or VB.NET?

    Yes we have new Access, 365 or that version 16, whatever.
    Is it painless to import old Access code to new? Have somebody tried it?

  4. #4
    PowerPoster
    Join Date
    Jun 2013
    Posts
    4,890

    Re: Convert VBA and VB6 code to C# or VB.NET?

    Quote Originally Posted by kutlesh View Post
    Yes we have new Access, 365 or that version 16, whatever.
    Is it painless to import old Access code to new? Have somebody tried it?
    I'm not an "Access-Guy" - perhaps a direct conversion-attempt (right from 2000 to 365) -
    is a "too large step to take".

    If that's the case (why not simply try it?) - then an intermediate import into an "in-between" Access-version might help...

    There's a few Access-experts here who will probably soon chime in...
    (if not, asking that question in the Office-section of this Forum will probably help).

    Olaf

  5. #5
    PowerPoster
    Join Date
    Feb 2017
    Posts
    2,204

    Re: Convert VBA and VB6 code to C# or VB.NET?

    Newer Access use C# and VB.NET or do they use VBA?

  6. #6

    Thread Starter
    Addicted Member kutlesh's Avatar
    Join Date
    Jun 2018
    Location
    Skopje, Macedonia
    Posts
    195

    Re: Convert VBA and VB6 code to C# or VB.NET?

    Yeess, we have lot of legacy code, made in VBA and Access 2000. Yes its easy to say, never use Access...

  7. #7
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,152

    Re: Convert VBA and VB6 code to C# or VB.NET?

    Older versions of VS had a converter included that would convert VB6 to VB.Net. It was far from perfect but did work to some degree. The last version that included it was VS2008.

  8. #8
    PowerPoster
    Join Date
    Jun 2013
    Posts
    4,890

    Re: Convert VBA and VB6 code to C# or VB.NET?

    Quote Originally Posted by Eduardo- View Post
    Newer Access use C# and VB.NET or do they use VBA?
    https://answers.microsoft.com/en-us/...a-fee61eadb901

    Olaf

  9. #9
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    6,223

    Re: Convert VBA and VB6 code to C# or VB.NET?

    Quote Originally Posted by kutlesh View Post
    Yes we have new Access, 365 or that version 16, whatever.
    Is it painless to import old Access code to new? Have somebody tried it?
    Yes, I've done this many times through the years. There was once talk coming from Microsoft that they were going to upgrade the VBA to .NET, but nothing ever materialized. Therefore, basically, all of the VBA is still VB6 (i.e., COM architecture based).

    I have VBA code in both Excel and Access that has migrated through every version of MS-Office. Occasionally there are some strange glitches, but never anything major. And, these glitches always have to do with small changes in the way properties and/or methods of Excel or Access objects work, and don't have anything to do with the core VBA language.

    Regarding the core VBA languages (excluding Excel and/or Access specific objects and members), I know of no differences between VBA and VB6, other than the explicit presence of the LongLong type, the LongPtr type, the PtrSafe API declaration directive, and the ability to run in a 64-bit environment.

    I suppose a couple of other differences are (in the VBA) the lack of User Controls, and the intrinsic controls are a bit different. Still, the core language is virtually identical to VB6.

    Good Luck,
    Elroy
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  10. #10
    PowerPoster
    Join Date
    Feb 2017
    Posts
    2,204

    Re: Convert VBA and VB6 code to C# or VB.NET?

    Quote Originally Posted by Schmidt View Post
    I misunderstood the question, I thought he wanted to convert VBA to .NET for code inside Access.

  11. #11
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    6,223

    Re: Convert VBA and VB6 code to C# or VB.NET?

    Quote Originally Posted by Eduardo- View Post
    I misunderstood the question, I thought he wanted to convert VBA to .NET for code inside Access.
    He has stated two different questions: 1) porting VB6 or VBA to C# or VB.NET, and 2) migrating VBA to newer versions of MS-Office. I've got no idea which is the primary question for Kutlesh.
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  12. #12
    Frenzied Member
    Join Date
    Dec 2008
    Posts
    1,310

    Re: Convert VBA and VB6 code to C# or VB.NET?

    I was a Qualified chartered Accountant, and then a Senior Analyst in IT in a Large bank, and the 2nd largest Telecommunications company in the world, for 20 years.
    I am retired now, but used to shudder at the amount of processing that was done in Excel spreadsheets.
    I still shudder when I think about it.
    But now I am also glad that it all exists, because MS cannot abandon VBA like it did with VB6 (and possibly is attempting with VB.NET ?)

    Rob

  13. #13
    Fanatic Member
    Join Date
    Jun 2012
    Posts
    932

    Re: Convert VBA and VB6 code to C# or VB.NET?

    Quote Originally Posted by Bobbles View Post
    (...and possibly is attempting with VB.NET ?)

    Rob
    Often wondered about that...
    Thanks all!

  14. #14

    Thread Starter
    Addicted Member kutlesh's Avatar
    Join Date
    Jun 2018
    Location
    Skopje, Macedonia
    Posts
    195

    Re: Convert VBA and VB6 code to C# or VB.NET?

    Yes I mixed two questions. Probably more appropriate is to upgrade old Access 2000 apps to the new Access 16.

    EDIT:

    Hmm, why I bother so much. Just upgrade the old apps in new Access.

    I asked this question because a thought crossed my mind. If you have ton of VBA code in Access 2000, what would you do to rework it in other newer and more powerful technology... Access is not very attractive.
    No new young programmers would like to work in Access VBA, sadly
    Last edited by kutlesh; Mar 15th, 2020 at 03:29 AM.

  15. #15
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    5,681

    Re: Convert VBA and VB6 code to C# or VB.NET?

    Quote Originally Posted by kutlesh View Post
    Yes I mixed two questions. Probably more appropriate is to upgrade old Access 2000 apps to the new Access 16.

    EDIT:

    Hmm, why I bother so much. Just upgrade the old apps in new Access.

    I asked this question because a thought crossed my mind. If you have ton of VBA code in Access 2000, what would you do to rework it in other newer and more powerful technology... Access is not very attractive.
    No new young programmers would like to work in Access VBA, sadly
    There is a bit of nuance to this question you're asking. You can't think in terms of converting VBA to C#/VB.Net. You see, VBA is more than just a language. It's an entire environment designed to help automate tasks within the Office Suit of products like Word. VBA is used within Access and as far as I know, it has no bindings to .Net. In this case there is no need to translate anything.

    However, Microsoft Office exports COM objects that allow you to control various thinks like Word documents and Excel spreadsheets from external applications. In this case, you question makes a lot more sense. You could write an application in C# that use these COM objects to interact with Office. You could have VB6 code that does the same thing that could be translated to VB.Net.

    TLDR;

    VBA is internal to Office and is based on COM. You can only use what Office allows you to use. If it doesn't allow you to use the .Net Framework or .Net Core then the question is moot. You stick with VBA.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena


    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. -jmcilhinney

  16. #16
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    18,993

    Re: Convert VBA and VB6 code to C# or VB.NET?

    One note about PtrSafe keyword... If converting 32bit to 64bit VBA, then I don't find that truly painless - has a learning curve. In addition, some UDT/Type declarations may need to be changed to reference 64bit members vs 32bit members. This is more of an issue if needing to do pointer math, calculating offsets from VarPtrs. Maybe there is a reliable site that has APIs and UDTs defined with PtrSafe 64bit declarations?
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  17. #17
    Hyperactive Member
    Join Date
    Jan 2020
    Posts
    418

    Re: Convert VBA and VB6 code to C# or VB.NET?

    visual basic code to java(b4a make app tool)。
    basic code to code(freebasic),Everything is possible. Many softwares do a very good job in this regard. The key is that they cannot be fully compatible, but they can be very convenient for some common applications. Very powerful.

  18. #18
    Hyperactive Member
    Join Date
    Jan 2020
    Posts
    418

    Re: Convert VBA and VB6 code to C# or VB.NET?

    freebasic software,have x32,x64 api,type declared

  19. #19
    Hyperactive Member
    Join Date
    Jan 2020
    Posts
    418

    Re: Convert VBA and VB6 code to C# or VB.NET?

    I use freebasic.exe to write special functions for loading and running dlls in memory. It took a lot of time to convert a 32-bit program to 64-bit, but the data structure has changed. There are still many places to pay attention to. This does cost a lot of money. Please ignore the following Chinese
    我曾经使用 freebasic 编写内存加载运行dll的特殊功能,32位程序转换到64位的时候花了大量时间,只是数据结构发生了变化,还有很多地方也要注意,这个确实要不少成本。

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width