6 ms·
Visual Basic for Applications Language Specification [pdf]
- KRAKRISMOTT 3y agoIs the language spec for Visual Basic 6 available anywhere?
- badsectoracula 3y agoI don't think VB6 (or really any prior VB) had a real spec, the language was basically QBASIC stitched on a form editor for VB1 and extended over time to add more stuff and after some point could also be embedded in other programs (hence "Visual Basic for Applications"). AFAIK this spec isn't even for VB6, but for a "VB7" (i.e. VB6 with a bunch of changes) that never really got a standalone version and Microsoft made a spec for after the fact once they decided to attempt to make the file formats used in Office an open standard. It is useful if you want to make a VB6 compatible parser but AFAIK those who attempted that had to "peek and poke" the real VB6 for various edge corners anyway.
- pjmlp 3y agoQuickBasic, not QBasic. They weren't the same, those that only experienced MS-DOS 5.0 QBasic keep mixing them up. QBasic was a stripped down version of QuickBasic. Not sure about you, talking in general.
- badsectoracula 3y agoStrictly speaking i don't think it was QuickBasic either (VB1 for DOS most likely was but IIRC there were minor language differences between the two), but in my message i didn't mean the exact product, just that it used an existing BASIC implementation they had with their take on making BASIC more Pascal-like. QBASIC is by far the most known implementation of that dialect. (i just made a search and found an article about VB1's history and VB1 was indeed based on an existing BASIC engine they called "Embedded Basic")
- ptx 3y agoVisual Basic clearly seems to have been aiming at QBasic/QuickBasic compatibility, in any case. For example, the CALL keyword in QBasic is almost useless: It allows you to call procedures without a DECLARE statement, but DECLARE statements are automatically generated on save anyway. In Visual Basic, even in version 1.0, it's completely useless because DECLARE statements are not required anymore, but both CALL and DECLARE are still in there in the language, presumably for compatibility.
- tonyedgecombe 3y agoI don't think so, or at least by VB5/6 they had moved on a long way. For instance VB6 compiled to native code rather than running as an interpreter. It could even create COM objects if you felt brave enough.
- DaiPlusPlus 3y ago> It could even create COM objects if you felt brave enough. Not just "brave enough" - but everyone, honestly. After VB4 and Windows 95, VB's raison d'etre was all about being a glue-language for anyone, regardless of ability level, to piece-together OLE/COM/ActiveX controls and components together onto a form/window surface and ship it the same day. ---- COM only requires bravery if you're lucky enough to be required to implement (or just consume), a COM service from C or a non-COM-blessed language. It is unfortunate that COM (honestly!) is a powerful platform feature built-in to Windows, but it's stagnated and permanently stuck in the year 1999 now - the lack of maintained documentation also makes it incredibly difficult to grok by newcomers. I'll bet there are more people in Gen Z who speak COBOL than feel comfortable around COM/COM+/DCOM.
- owlstuffing 3y agoCOM has become iunknown ;)
- pjmlp 3y agoAnd later extended with IInspectable.
- pjmlp 3y agoCOM is the main Windows API since Windows Longhorn .NET ideas were reintroduced as COM libraries in Windows Vista. Yes, the tooling is still clunky, regardless it being the main way to expose Windows APIs nowadays.
- badsectoracula 3y agoWith "i don't think so" you meant the part about "extended over time to add more stuff"? Even VB1 worked by compiling the statements to bytecode, changing that to emit machine language instead wasn't such a big leap that they'd need to make a new compiler. It was an important change (the perception of which was most likely also magnified by the new IDE UI) but it was still an evolution over VB4.
- deaddodo 3y agoEverything has a spec. What do you mean? It might not have had a written/formal spec, but Microsoft VB6 compiler itself is the spec in that case. I would assume that by VB6, however, something had been written down internal to MS.
- badsectoracula 3y agoI meant a written spec, at least that is what i assume one would mean when they ask for a language spec.
- secondcoming 3y agoYears and years ago I wrote a basic VB6 -> JVM compiler. I could never find any spec other than the MSDN documentation, so it was basically trial and error to figure out the grammar. Found a bug or two in the VB6 IDE.
- fafalone 3y agoJust drop the parts about PtrSafe, LongPtr and LongLong, and it's the same.
- signaru 3y agoAlthough not "official" by MS, perhaps the one from ANTLR's collection [0] is a good start (there are also other ANTLR VB6 grammars documented elsewhere). It does require knowing ANTLR's meta syntax, but it's not that far from (E)BNF. [0] https://github.com/antlr/grammars-v4/tree/master/vb6 https://github.com/antlr/grammars-v4/tree/master/vb6
- account-5 3y agoAs someone stuff using VBA at work this is really good. One niggle for me would be the lack of a section on VBA arrays. They're probably the most confusing things to use in VBA closely followed by error handling.
- wood_spirit 3y agoCan this trace its roots back to the spec BillG reviewed of lore? https://www.joelonsoftware.com/2006/06/16/my-first-billg-review/ https://www.joelonsoftware.com/2006/06/16/my-first-billg-rev...
- zxspectrum1982 3y agoIs there any open source implementation of VBA one can add to some application with limited effort? I'm thinking about adding macro-like functionality to one of my business applications and VBA would be the best, considering my users and Excel users intersect pretty well.
- amichal 3y agoI dont know about open source. But back back around 2000 it was fairly common to implement a "VBA host". It was also easy, a few dev days to scaffold and minutes to hours of dev time to expose functions. We did it with a suite of related applications (used internally by a early ebook punlisher) that interacted a lot with Office. Introspection, auto-complete and integrated help documentation all worked and technically minded editor staff could automate lots of thier work with Visual Studio provided IDE and debuggers etc
- doubloon 3y agoIMHO the trick is that any moderately useful and modern VBA is likely to go way beyond the base specification. - UserForms GUI (which this does not touch on at all) - Microsoft libraries like mscorlib and Microsoft Scripting Runtime, to get stuff like ArrayList and FileSystemObject. - Excel VBA is kind of notorious for mixing Excel code with the VBA, using cells of the sheet as data storage, using formulas inside of cells to calculate values, etc. For example to store a list of values and sort it, they might put the data into a tab of the spreadsheet and call Excel functions to sort it inside the spreadsheet instead of building a list in VBA and sorting it in VBA. So I think an open source useful VBA clone would probably also need to be an Excel clone and also a clone of a bunch of Microsoft libraries
- mcbishop 3y agoI love your comment. I'm guessing that it'd be very difficult to clone Excel's relatively-new dynamic-array-formula functionality (with comparable performance).
- agumonkey 3y agoand IIRC, datatype conversion made through excel formatting options. change cell display to get decimal :) fun
- bvan 3y agoHey look, proper documentation! Even has clear IP classification in front and revision history! How standards have fallen…
- zubairq 3y agoWow there is a lot to VBA!