Logo of Vovisoft
 

PreviousBack to Vovisoft homeNext
 

What is Visual Basic?

 
VISUAL COMPONENTS + BASIC LANGUAGE PROGRAMMING CODES
 
The Visual Components (Controls)
 
 
1. Intrinsic (simple) controls:
Form, Label, Textbox, Listbox, Combobox, Picture, Frame, Image, CommandButton, Checkbox, Optionbutton etcẨ
Use Property window to edit control properties.
 
2. ActiveX (sophisticated) controls:
Listview, Treeview, SSTab, DBGrid, DBList, DBCombo, MSFlexGrid etcẨ
May use special control Property Pages to edit sophisticated control properties. Open the Property Pages by right clicking on the ActiveX Control then pick the menu item Properties from the pop-up menu.
 
3. The Basic Language code behind the events
Code runs as a result of an event. Events occur when you click on a control, you strike a key, a control receives or looses a focus etc.. The events are reported to you by the Window Operating System, it’s up to you to use it for whatever purpose.
Eg: In the routine below, when the Commandbutton CmdShowTime is clicked, the System Date & Time will be assigned to the Caption of Label LblCurrentTime.
 
 
4. Relation to Window environment
Like Visual Basic’s form, a window is an object that represents a rectangular area of the screen. A window can contain other windows known as child windows. Child windows used in dialog boxes typically use one of the standard window definitions or one defined in a DLL, and are usually called controls.
A window has the following features:
  •  
    Attributes: These vary from attributes related to appearance such as size, position, and visibility, to functional attributes that define the performance of the window, how it handles keystrokes and mouse events, and so on. This is similar to Visual Basic Properties.
  •  
    Functionality: Each window has some underlying functionality. The functionality of a window can be enabled (made active) by external messages through the Windows function, or directly through Application Programming Interface (API) function calls. This is similar to Visual Basic Methods.
  •  
    Messages: Every window has associated with it a special function called a Windows function. This function receives messages from a variety of sources, the most important in most cases being event messages from the Windows environment itself. This is similar to Visual Basic Events.
Visual Basic controls often contain standard Windows controls. Many VB properties and events correspond on a one-to-one basis with standard Windows attributes and messages.
This makes Visual Basic very powerful. Because a VB form is a window, virtually every Windows API function or message can be used with a VB form. When a VB control encapsulates a standard Windows control, virtually every API function or message that accesses the underlying Windows control will also work on the Visual Basic control.
As a result, a very large percentage of the hundreds of functions provided by Windows is not only accessible but is also useful to the Visual Basic programmer.
In brief, Visual Basic makes available a lot of Windows functions to you application program. It simplifies the job of searching through thousands of Windows functions to identify which one you need and then to find out how to use it.
Following is how an API is declared and used in Visual Basic:
 
Public Declare Function SendMessageArray Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long
Public Const LB_SETTABSTOPS = &H192
R = SendMessageArray(List1.hwnd,LB_SETTABSTOPS,3,Tabstop(1))
 
The compilation process:
 
Source Code compiled (converted) to give Object Code
Object Code linked (make reference to Subroutines and Functions in libraries) to give
Executable module (i.e. .exe application file)
 
OCX, DLL, DRV
 
To run a Visual Basic program you often need the ActiveX components, i.e. file names with extension DLL, DRV, OCX, such as COMCTL32.OCX, COMDLG32.OCX. DLL stands for Dynamic Link Library. When a DLL is created, we specify which of the Sub/Functions should be made available to (i.e. accessible from) other running applications. This is known as exporting the function.
When you create a Windows executable file, the linker scans your program’s object files and makes a list of those functions that are not present and the DLL in which they can be found. The process of specifying where each function can be found is known as importing the function.
When your application runs, any time it needs a function that is not in the executable file, Windows loads the DLL into the memory so that all of its functions become accessible to your application. At that time, the address of each function is resolved and dynamically linked into your applicationỔhence the term dynamic linking.
The major Windows DLLs are:
KERNEL32.DLL Low-level operating functions. Memory management, task management, resource handling, and related operations.
USER32.DLL Functions relating to Windows management. Messages, menus, cursors, carets, timers, communications, and most other non-display functions.
GDI32.DLL The Graphics Device Interface library. This DLL contains functions relating to device output. Most drawing, display context, metafile, coordinates, and font functions are in this DLL.
COMDLG32.DLL,LZ32.DLL, VERSION.DLL These DLLs provide additional capabilities including support for common dialogs, file compression, and version control.
 
 
COMCTL32.DLL This DLL implements a new set of windows controls such as the tree list and rich text edit control. This DLL was initially created for Windows 95, but is now available for Windows NT as well.
MAPI32.DLL This DLL provides a set of functions that lets any application work with electronic mail.
NETAPI32.DLL This DLL provides a set of API functions for access and control of networks.
ODBC32.DLL This is one of the DLLs that implements ODBCỔOpen Database Connectivity. These functions provide a standard API that can be used to work with different types of databases.
WINMM.DLL This DLL provides access to a system’s multimedia capabilities.
OCX is the new name for OLE (Object Linking Embedded). It is a form of DLL. The DLL files for hardware device drivers have the extension DVR. To deliver an application (i.e. your VB program) you need to run the Package and Deployment Wizard. This Wizard will include all the files required by your program at run-time on the computer that it is installed (setup).
 
 
 

 

PreviousBack to Vovisoft homeNext