两者的区别是什么?我一直认为VBA是VB的“残缺”版本,但当一个朋友前几天问我,我不知道实际的区别是什么。

另外,当你使用Excel时,你用的是VB还是VBA ?


当前回答

VB (Visual Basic only up to 6.0) is a superset of VBA (Visual Basic for Applications). I know that others have sort of eluded to this but my understanding is that the semantics (i.e. the vocabulary) of VBA is included in VB6 (except for objects specific to Office products), therefore, VBA is a subset of VB6. The syntax (i.e. the order in which the words are written) is exactly the same in VBA as it would be in VB6, but the difference is the objects available to VBA or VB6 are different because they have different purposes. Specifically VBA's purpose is to programatically automate tasks that can be done in MS Office, whereas VB6's purpose is to create standard EXE, ActiveX Controls, ActiveX DLLs and ActiveX EXEs which can either work stand alone or in other programs such as MS Office or Windows.

其他回答

VB (Visual Basic only up to 6.0) is a superset of VBA (Visual Basic for Applications). I know that others have sort of eluded to this but my understanding is that the semantics (i.e. the vocabulary) of VBA is included in VB6 (except for objects specific to Office products), therefore, VBA is a subset of VB6. The syntax (i.e. the order in which the words are written) is exactly the same in VBA as it would be in VB6, but the difference is the objects available to VBA or VB6 are different because they have different purposes. Specifically VBA's purpose is to programatically automate tasks that can be done in MS Office, whereas VB6's purpose is to create standard EXE, ActiveX Controls, ActiveX DLLs and ActiveX EXEs which can either work stand alone or in other programs such as MS Office or Windows.

VBA是Visual Basic for Applications的缩写,所以它是VB的“for Applications”脚本兄弟。 VBA确实可以在Excel中使用,但也可以在其他办公应用中使用。

使用VB,可以创建一个独立的windows应用程序,这是VBA无法做到的。

但是,开发人员可以将VBA“嵌入”到他们自己的应用程序中,作为一种脚本语言来自动化这些应用程序。

编辑:从VBA常见问题:

问:什么是Visual Basic for Applications? A. Microsoft Visual Basic for Applications (VBA)是一个嵌入式编程环境,旨在使开发人员能够使用Microsoft Visual Basic的全部功能构建自定义解决方案。使用承载VBA的应用程序的开发人员可以自动化并扩展应用程序功能,从而缩短自定义业务解决方案的开发周期。

注意VB。NET甚至是另一种语言,它只与VB共享语法。

VBA。VBA的意思是Visual Basic for Applications,它用于Office文档中的宏。它不能访问VB。NET特性,所以它更像是一个VB6的修改版本,附加组件能够在文档上工作(就像VBA中的Excel工作表)。

VBA是Visual Basic for Applications的缩写,它是一种用于Office Suite的Visual Basic实现。

它们之间的区别是VBA嵌入在Office文档中(这是Office的一个特性)。VB是开发应用程序的ide/语言。

VB不是一种语言。VB是一个承载VBA的程序,就像Office承载VBA一样。VB是一组App对象,就像Word和Excel一样,还有一个表单包,就像Office一样。

所以你只能在VB中编写VBA代码。

PS这个信息在VB问题页面的info选项卡上。

来自VBA信息

VBA 6于1998年发布,包含大量授权主机,其中包括:Office 2000 - 2010、AutoCAD、PI Processbook和独立的Visual Basic 6.0