绑定 Microsoft Word 对象

模块 BindWord 后期绑定 Microsoft Word 对象,调用方法如下:

Dim sProg As String
sProg = “Word”
Dim oWord As Object
Call BindWord(True)

Public Sub BindWord(ByVal bVisible As Boolean)
If Not oWord Is Nothing Then Exit Sub
On Error Resume Next
Set oWord = GetObject(, sProg & “.Application”)
If Err.Number <> 0 Then ‘没有打开
Err.Clear
Set oWord = CreateObject(sProg & “.application”)
If Err.Number <> 0 Then ‘没有正确安装
Err.Clear
Exit Sub
End If
oWord.Visible = bVisible
End If
On Error GoTo 0
End Sub

绑定 Microsoft Excel 对象

模块 BindExcel 后期绑定 Microsoft Excel 对象,调用方法如下:

Dim sProg As String
sProg = “Excel”
Dim oExcel As Object
Call BindExcel(True)

Public Sub BindExcel(ByVal bVisible As Boolean)
If Not oExcel Is Nothing Then Exit Sub
On Error Resume Next
Set oExcel = GetObject(, sProg & “.Application”)
If Err.Number <> 0 Then ‘没有打开
Err.Clear
Set oExcel = CreateObject(sProg & “.application”)
If Err.Number <> 0 Then ‘没有正确安装
Err.Clear
Exit Sub
End If
oExcel.Visible = bVisible
End If
On Error GoTo 0
End Sub

绑定 AutoCAD 对象

模块 BindAutoCAD 后期绑定 AutoCAD 对象,调用方法如下:

Dim oAutoCAD As Object
Call BindAutoCAD(True)

Public Sub BindAutoCAD(ByVal bVisible As Boolean)
If Not oAutoCAD Is Nothing Then Exit Sub
On Error Resume Next
Set oAutoCAD = GetObject(, “Autocad.Application”)
If Err.Number <> 0 Then ‘没有打开
Err.Clear
Set oAutoCAD = CreateObject(“Autocad.application”)
If Err.Number <> 0 Then ‘没有正确安装
Err.Clear
Exit Sub
End If
oAutoCAD.Visible = bVisible
End If
If Err.Number <> 0 Then Err.Clear
On Error GoTo 0
End Sub

Visual Basic

Visual Basic (VB)

Visual Basic (VB) is an event-driven programming language and environment from Microsoft that provides a graphical user interface (GUI) which allows programmers to modify code by simply dragging and dropping objects and defining their behavior and appearance. VB is derived from the BASIC programming language and is considered to be event-driven and object-oriented.

VB is intended to be easy to learn and fast to write code with; as a result, it is sometimes called a rapid application development (RAD) system and is used to prototype an application that will later be written in a more difficult but efficient language.

The last version of VB, Visual Basic 6, was released in 1998, but has since been replaced by VB .NET, Visual Basic for applications (VBA) and Visual Stuido .NET. VBA and Visual Studio are the two frameworks most commonly used today.

Visual Basic features and characteristics

VB is a GUI-based development tool that offers a faster RAD than most other programming languages. VB also features syntax that is more straightforward than other languages, a visual environment that is easy to understand and high database connectivity. 

Visual Basic was designed to be a complete programming language that contained ordinary features, such as string processing and computation. The visual environment is characterized by a drag-and-drop feature which allows programmers to build a user interface that is easy to use, even for developers with minimum experience.

While these features of VB are advantageous, there are others that can have a negative effect. The VB programming environment requires a large amount of memory, both for the initial installation and to run efficiently afterwards. The graphical features of the programming tool take up a large amount of space and require a significant amount of memory.

Furthermore, Visual Basic is not useful when developing programs that require a lot of processing time, like games, and the use of VB is restricted to Microsoft operating systems (OS).

Finally, with C languages, programmers can feasibly locate and use the defined values for variable data in a computer program at declaration time. This initialization practice is something that isn’t easily done with VB.

How Visual Basic is used

The structure of VB is designed to allow programmers to use the environment to write executable files (exe files). Also, using VB, developers can create programs that can be utilized as a front end to databases. VB tools can help programmers develop applications or complete software while still allowing them to modify and revise their work accordingly.

The most popular type of Visual Basic in use today is VBA. VBA is a version of Visual Basic that can be used to program Microsoft Office apps, such as Excel and PowerPoint. However, it can only be used to modify existing apps; VBA cannot be used to create new apps.

Typical users engage VBA to make repeated, everyday tasks less monotonous through the use of macros. Macros automate almost any activity — such as performing word and data processing or generating custom charts and tables. For example, a typical user might write a macro that allows them to create and fill a spreadsheet with a single click. Computer professionals use VBA and macros in more complicated ways. Programmers will often write macros that can replicate large portions of code or define specific languages.

Businesses and organizations can use VBA to customize Excel for their unique purposes, such as pulling certain statistics or information from a spreadsheet. Businesses and organizations can also use VBA externally, or in non-Microsoft applications, by applying a technology called a component object model (COM) interface that enables commands to communicate across computer boundaries. This allows VBA to be used on an enterprise-specific application.

Benefits of Visual Basic

The BASIC programming language, which VB is derived from, is simple and easy to work with, especially when writing exe files.

However, VB becomes extremely beneficial when used with Microsoft’s COM interface. The COM components can be written in various languages and then integrated using VB. Additionally, VB provides not only a programming language, but an integrated development environment (IDE) that has been written and optimized to best support RAD. This allows programmers to easily build GUIs and connect them to functions within the application.

Furthermore, the Visual Basic IDE provides views of the management of the program structure that are easy to understand.

Overall, VB enables the rapid development of Windows based applications while also assisting in the access of databases by using ActiveX data objects (ADO) while allowing programmers to use ActiveX control and various objects.

History of Visual Basic

Visual Basic was first introduced in 1991; it is considered the third generation of event-driven programming languages. Various Windows programs were developed throughout the 1990s using VB.

VB continued to evolve throughout the 1990s until Visual Basic 6 was released in 1998, which was replaced by VB .NET. However, Visual Basic for Applications, which is most commonly used today to automate Microsoft Office tasks, is highly compatible with the classic VB 6.

主要编程语言及应用场合

1.Java

Java 作为构建现代企业Web应用后端的最常用编程语言之一,是一门必须了解(掌握)的编程语言。网站开发人员凭借Java和基于 Java 的框架可以为各种用户创建可扩展性的 Web 应用。Java 也是用来开发 Android 系统原生应用的主要编程语言之一。

2.JavaScript

现代网站离不开 JavaScript。如果你想为你的网站创造互动,或者用时下流行的 JavaScript 框架搭建一个用户界面,那么 JavaScript 是最佳选择。

3.C#

C# 是 Windows 开发环境下的主要语言。无论你是用微软云计算平台 Windows Azure 和 .NET 框架来创建现代网页应用,还是开发 Windows 设备上的应用,又或者是为你的企业开发功能强大的桌面应用,C# 能够迅速地帮助你驾驭微软提供的所有功能。可以开发游戏吗?当然。非常流行的 Unity 游戏开发引擎就把 C# 作为了自己的主要开发语言之一。

4.PHP

网页应用需要加载数据,这个时候怎么办?用 PHP。PHP 语言和 MySQL 一类的数据库,是开发现代网页应用的最基本工具。PHP 应用于绝大多数的数据驱动网站,也是内容管理系统的基础技术,比如 WordPress,系统地管理你的网站内容,使之更合理。

5.C++

前面几个太难,想了解简单一点的?那就试试 C++ 吧。当你需要直接访问硬件获得最大的处理能力时,C++ 是不二选择。它是开发强大的桌面软件、硬件加速的游戏,以及开发在桌面、控制端和移动设备上的内容密集型应用的最佳编程语言。

6.Python

Python 几乎可以做任何编程工作。Web 应用、用户交互界面、数据分析、统计等等——不管是什么问题,你总能在 Python 中找到需要的框架。近期,Python 又成为了数据科学家用来筛选大型数据集的重要工具。

7.C

为何 C 语言如此经久不衰?答案是“小身材,大功能”。因为 C 语言占用的空间很小,但是处理速度和功能却很强大。如果你需要为嵌入式系统开发软件,需要处理系统内核或者想要利用手头的每一点资源,除了 C 语言,还有更好的选择吗?

8.SQL

数据很重要,它无处不在,它复杂多变。这时候,你需要 SQL 来帮助你以快速、可重复且可靠的方式准确找到信息。有了 SQL,你可以轻轻松松地从庞大复杂的数据库中查询、提取有意义的数据。

9.Ruby

想要快速地创建项目吗?想为你的下一个大型 Web 应用构思一个原型思路吗?Ruby 可以帮你实现这一切。Ruby 是为简单快捷的面向对象编程(面向对象程序设计)而创的脚本语言,它简单易学又异常强大,全球数以万计的流行 Web 应用都在用 Ruby。

10.Objective- C

如果你想要开发 iOS 系统的应用,那就很有必要了解 Objective- C。尽管苹果的新编程语言 Swift 被炒的沸沸扬扬,Objective- C 仍是开发苹果生态系统应用的基础语言。掌握了 Objective- C 和 Xcode 这两种苹果官方的软件开发工具,进驻 App Store 指日可待。

11.Perl

Perl 很难理解,也很混乱,它还是一个超级强大的编程语言,是所有网络安全工具的重要组成部分之一。从发明到至今,Perl 一直发挥着其强大作用,也始终被认为是 IT 专业人士的重要工具。

12..NET

.NET 其实算不上一门真正的编程语言,但是作为微软的一个重要开发平台,它广泛应用于云服务,服务器以及应用的开发。得益于近期微软的开源计划,.NET 现在亦被应用于 Google 和苹果的开发平台。其带来的最终好处是,利用 .NET 和任何一种编程语言,你都可以轻松地开发一个兼容大多数平台的应用。

13.VB

Visual Basic 是 .NET 平台的重要语言之一,它才是真正为你干活的角色。Visual Basic 可以让你开发一款应用来辅助你的工作,使Office软件实现自动化操作,替你完成任务量庞大的计算工作,比如 Excel,当然还可以简化日常任务。

14.R

R 语言推动了大数据革命,也是数据分析研究者在 2015 年不可不知的编程语言之一。从科学和商业到娱乐和社会媒体,每一个需要统计分析的领域都少不了 R 语言。

15.Swift

Swift 是编程家族中小字辈,作为苹果 Mac 和 iOS 系统的开发语言,它新颖、快速且高效,已然成为全世界开发人员的新宠。Swift 拥有各种强大的功能和简洁明了的语法结构。掌握了 Swift,再加上一台 Mac 电脑,任何人都有机会为 iOS 系统或 Mac OS X 开发出重量级的应用。

16.LISP

LISP 语言(LISP,List Processing 的缩写)是第一个声明式系内函数式程序设计语言,有别于命令式系内过程式的 C、Fortran 和面向对象的 Java、C# 等结构化程序设计语言。它适用于符号处理、自动推理、硬件描述和超大规模集成电路设计等。特点是,使用表结构来表达非数值计算问题,实现技术简单。