I.T. Discussion Community!
-Collapse +Expand
VB Classic
Search VB Classic Group:

Advanced
-Collapse +Expand VB Classic Store
   ► KBProgrammingVB Classic   Print This    All Groups  

VB Classic KB: VB Classic Topic

Microsoft Visual Basic (Versions 1 through 6)

Topics

36 Articles Found in the VB Classic Topic  (or one of the sub-topics in bold above)

  KB Article    

Mike Prestwood
1. Mimic Short-Circuit Evalution in VB

Short-circuit evaluation is a feature of most languages where once an evaluation evaluates to False, the compiler evaluates the whole expression to False, exits and moves on to the next code execution line. In VB Classic, the if statement does not support short-circuit evaluation but you can mimic it. Use either an if..else if..else if statement or nested if statements. You will find that your code that makes use of this technique will be clearer and easier to maintain than the short-circuit equivalent and faster than ingnoring the issue.

Posted to KB Topic: Tool Basics
9 years ago

Tip
Nothing New Since Your Last Visit
6755
Hits

Mike Prestwood
2. VB Classic Array (x = Array())

Arrays in VB Classic use a 0-based indice. UBound returns -1 if the array has no elements, 0 if it has 1, 1 if it has 2, etc.

7 years ago

Code
Nothing New Since Your Last Visit  
7930
Hits

Mike Prestwood
3. VB Classic Assignment (=)

VB Classic uses = for it's assignment operator.

Posted to KB Topic: Tool Basics
9 years ago

Code
Nothing New Since Your Last Visit
4840
Hits

Mike Prestwood
4. VB Classic Associative Array (Collection)

In addition to Add and Item, collections also offer Count and Remove. Notice that Add uses the format of Value, Key (which is backwards from many other languages).

Posted to KB Topic: Language Details
9 years ago, and updated 8 years ago

Code
Nothing New Since Your Last Visit
7415
Hits

Mike Prestwood
5. VB Classic Case Sensitivity (No)

VB Classic is not case sensitive. If you type any other case for commands or variables, VB Classicwill change it to the "accepted" or "defined" case. For example, if you type msgbox it is converted to MsgBox.

Posted to KB Topic: Tool Basics
9 years ago, and updated 8 years ago

Code
Nothing New Since Your Last Visit
5558
Hits

Mike Prestwood
6. VB Classic Class..Object (Yes)

One class per file. File must use a .cls extension (instead of .bas). You can include your classes in your project (a traditional OOP approach) or compile them to a DLL or ActiveX EXE, register them, and use them that way (a uniquely VB approach).

Posted to KB Topic: Language Details
9 years ago, and updated 8 years ago

Code
Nothing New Since Your Last Visit
4533
Hits

Mike Prestwood
7. VB Classic Code Blocks (End Xxx)

VB Classiccode blocks are surrounded by statement ending keywords that all use End such as End Sub, End If, and WEnd.

Posted to KB Topic: Tool Basics
9 years ago, and updated 8 years ago

Code
Nothing New Since Your Last Visit
6377
Hits

Mike Prestwood
8. VB Classic Comments (' or REM)

Commenting Code
VB Classic, like all the VB-based languages, uses a single quote (') or the original class-style basic "REM" (most developers just use a quote). VB Classic does NOT have a multiple line comment.

Directives - #

Directives are sometimes called compiler or preprocessor directives. A # is used for directives within VB Classic code. VB Classic offers only an #If..then/#ElseIf/#Else directive.

Posted to KB Topic: Tool Basics
9 years ago, and updated 8 years ago

Code

KB Post
Nothing New Since Your Last Visit
9004
Hits

Mike Prestwood
9. VB Classic Comparison Operators (=, <>)

Save as VB Classic. Common comparison operators:

= equal
<> not equal
< less than
> greater than
<= less than or equal
>= greater than or equal
Posted to KB Topic: Tool Basics
9 years ago, and updated 8 years ago

Code
Nothing New Since Your Last Visit
6413
Hits

Mike Prestwood
10. VB Classic Constants (Const kPI = 3.1459)

Scope can be Public, Global, or Private. The use of the newer Public keyword is preferred to the older Global. Private Const is the same as just specifying Const.

Posted to KB Topic: Tool Basics
9 years ago, and updated 8 years ago

Code
Nothing New Since Your Last Visit
6405
Hits

Mike Prestwood
11. VB Classic Constructors (Class_Initialize)

When an object instance is created from a class, VB6 calls a special parameter-less sub named Class_Initialize. Since you cannot specify parameters for this sub, you also cannot overload it.

When a class is destroyed, VB6 calls a special sub called Class_Terminate.

Posted to KB Topic: OOP
8 years ago

Code
Nothing New Since Your Last Visit  
9368
Hits

Mike Prestwood
12. VB Classic Custom Routines (Sub, Function)

VB Classic is a non-OOP language with some OOP features. It offers both Subs and Functions. A Sub does not return a value while a Function does. When Subs and Functions are used in a class module, they become the methods of the class.

Posted to KB Topic: Language Details
9 years ago, and updated 8 years ago

Code

KB Post
Nothing New Since Your Last Visit
8025
Hits

Mike Prestwood
13. VB Classic Deployment Overview

VB applications require the VB runtime DLL (for version 6, it's VB600.DLL) plus any additional dependencies you've added such as Crystal Reports, ActiveX controls, and DLLs.

You can use any of the many free and commercially available installation packages.

Posted to KB Topic: Tool Basics
8 years ago

Code
Nothing New Since Your Last Visit
5472
Hits

Mike Prestwood
14. VB Classic Destructor

When an object instance is destroyed, VB6 calls a special parameter-less sub named Class_Terminate. For example, when the variable falls out of scope. Since you cannot specify parameters for this sub, you also cannot overload it.

When an object instance is created from a class, VB6 calls a special sub called Class_Initialize.

Posted to KB Topic: OOP
8 years ago

Code
Nothing New Since Your Last Visit  
7889
Hits

Mike Prestwood
15. VB Classic Development Tools

Languages Focus: Development Tools

Primary development tool(s) used to develop and debug code.

VB Classic Development Tools

Microsoft Visual Basic 1...6. VB Classic is not compatible with VB.Net.

Posted to KB Topic: Tool Basics
9 years ago, and updated 8 years ago

Code
Nothing New Since Your Last Visit
4937
Hits

Mike Prestwood
16. VB Classic Empty String Check (Len(s&vbNullString))

In VB Classic, you have to add an empty string to the value being compared in order to get consistent results. For example, add &"" to your string varilable or it's code equivalent &vbNullString. Then compare to an empty string or verify it's length to 0 with Len.

8 years ago

Code
Nothing New Since Your Last Visit
6647
Hits

Mike Prestwood
17. VB Classic End of Statement (Return)

Languages Focus: End of Statement

In coding languages, common End of statement specifiers include a semicolon and return (others exist too). Also of concern when studying a language is can you put two statements on a single code line and can you break a single statement into two or more code lines.

VB Classic End of Statement

A return marks the end of a statement and you cannot combine statements on a single line of code. You can break a single statement into two or more code lines by using a space and underscore " _".

Posted to KB Topic: Tool Basics
9 years ago, and updated 8 years ago

Code
Nothing New Since Your Last Visit
5106
Hits

Mike Prestwood
18. VB Classic File Extensions
  • .BAS = VB source code file.
  • .CLS = VB class file (one class per file).
9 years ago, and updated 8 years ago

Code
Nothing New Since Your Last Visit
4738
Hits

Mike Prestwood
19. VB Classic If Statement (If..ElseIf..Else..End If)

The End If is optional if you put your code on a single line.

Posted to KB Topic: Tool Basics
9 years ago, and updated 8 years ago

Code
Nothing New Since Your Last Visit
6479
Hits

Mike Prestwood
20. VB Classic Inheritance (No, but see Implements.)

VB classic supports only a single "level" of interface inheritance (abstract class to implimentation class). See Implements in VB's help.

Posted to KB Topic: OOP
9 years ago, and updated 8 years ago

Code
Nothing New Since Your Last Visit
6407
Hits

Mike Prestwood
21. VB Classic Inheritance-Multiple (Not Supported)

VB classic supports only a single "level" of inheritance (abstract class to implimentation class).

Posted to KB Topic: OOP
9 years ago, and updated 8 years ago

Code
Nothing New Since Your Last Visit
4408
Hits

Mike Prestwood
22. VB Classic Interfaces

VB6 has limited support for interfaces. You can create an interface of abstract methods and properties and then implement them in one or more descendant classes. It's a single level implementation though (you cannot inherit beyond that). The parent interface class is a pure abstract class (all methods and properites are abstract, you cannot implement any of them in the parent class).

In the single level descendant class, you have to implement all methods and properties and you cannot add any. Your first line of code is Implements InterfaceName.

Posted to KB Topic: OOP
9 years ago, and updated 8 years ago

Code
Nothing New Since Your Last Visit
7188
Hits

Mike Prestwood
23. VB Classic Left of String

VB Classic Left of String

Posted to KB Topic: Commands
9 years ago

Code
Nothing New Since Your Last Visit
5131
Hits

Mike Prestwood
24. VB Classic Literals (quote)

Literals are quoted as in "Prestwood". If you need to embed a quote use two quotes in a row.

Posted to KB Topic: Tool Basics
9 years ago, and updated 8 years ago

Code
Nothing New Since Your Last Visit
6572
Hits

Mike Prestwood
25. VB Classic Logical Operators (and, or, not)

VB Classic logical operators:

and and, as in this and that
or or, as in this or that
Not Not, as in Not This

Posted to KB Topic: Language Basics
8 years ago, and updated 8 years ago
(3 Comments , last by MacKenzie.V )

Code

Article
Nothing New Since Your Last Visit  
11177
Hits

Mike Prestwood
26. VB Classic Member Method (sub, function)

VB classic uses the keywords sub and function. A sub does not return a value and a function does. Many programmers like to use the optional call keyword when calling a sub to indicate the call is to a procedure.

Posted to KB Topic: OOP
9 years ago, and updated 8 years ago

Code
Nothing New Since Your Last Visit
6178
Hits

Mike Prestwood
27. VB Classic Member Visibility

In VB Classic, the keywords Private, Friend, Public, and Static are used to set access levels for declared elements.

Posted to KB Topic: OOP
8 years ago

Code
Nothing New Since Your Last Visit
6261
Hits

Mike Prestwood
28. VB Classic Overloading (Not Supported)

Developer defined overloading in VB Classic:

  • Operator - No
  • Method - No
Posted to KB Topic: Language Details
9 years ago, and updated 8 years ago

Code
Nothing New Since Your Last Visit
5004
Hits

Mike Prestwood
29. VB Classic Overview and History

Language Overview: Class based language. Although you can create classes, VB Classic is not fully OOP. It is a traditional language with a few OOP extensions. You code in a traditional approach using functions, procedures, and global data, and you can make use of simple classes to help organize your reusable code. It also supports one-level abstract class to implemented class using the Implements keyword.

Target Platforms: Microsoft Visual Basic 6 is most suitable for creating Windows desktop applications that use the VB600.DLL runtime DLL within Microsoft Windows.

Posted to KB Topic: Tool Basics
9 years ago, and updated 8 years ago

Code
Nothing New Since Your Last Visit
5783
Hits

Mike Prestwood
30. VB Classic Parameters (ByRef, ByVal)

By Reference or Value
For parameters, you can optionally specify ByVal or ByRef. ByRef is the default if you don't specify.

9 years ago, and updated 8 years ago

Code
Nothing New Since Your Last Visit  
6113
Hits

Mike Prestwood
31. VB Classic Report Tools Overview

Crystal Reports was very popular with VB Classic developers and came bundled with Visual Basic 3 through 6. VB6 offers both Crystal Reports and the new Microsoft Data Report Designer.

Posted to KB Topic: Tool Basics
9 years ago, and updated 9 years ago

Code
Nothing New Since Your Last Visit
5978
Hits

Mike Prestwood
32. VB Classic Self Keyword (Me)

The Me keyword is a built-in variable that refers to the class where the code is executing. For example, you can pass Me from one module to another.

Posted to KB Topic: Language Details
8 years ago

Code
Nothing New Since Your Last Visit
6572
Hits

Mike Prestwood
33. VB Classic String Concatenation (& or +)

Although you can use either a & or a + to concatenate values, my preference is to use a + because more languages use it. However, if you use & then some type conversions are done for you. If you use + you will sometimes have to cast a value to concatenate it. For example, you will have to use CStr to cast a number to a string if you use the + operator as a concatenation operator.

Posted to KB Topic: Tool Basics
9 years ago, and updated 8 years ago

Code
Nothing New Since Your Last Visit
5865
Hits

Mike Prestwood
34. VB Classic Unary Operators

An operation with only one operand (a single input) such as + and -.

Posted to KB Topic: Tool Basics
9 years ago, and updated 8 years ago

Code
Nothing New Since Your Last Visit
5737
Hits

Mike Prestwood
35. VB Classic Variables (Dim x As Integer)

VB Classic is a loosely typed language. Declaring variables is optional unless you use the Option Explicit statement to force explicit declaration of all variables with Dim, Private, Public, or ReDim. Using Option Explicit is strongly recommended to avoid incorrectly typing an existing variable and to avoid any confusion about variable scope.

Undeclared variables are variants. To specifically declare a variant, use:

Dim x As Variant
Dim x 

Common data types include Byte (0..255), Boolean, Integer (2-byte integers), Long (4-byte integers), Currency, Single (32-bit number), Double (64-bit number), Date, String, and variant.

Variables declared with Dim at the module level are available to all procedures within the module. At the procedure level, variables are available only within the procedure.

Posted to KB Topic: Tool Basics
9 years ago, and updated 8 years ago

Code

KB Post
Nothing New Since Your Last Visit
7914
Hits

Mike Prestwood
36. Visual Basic User Group Meeting Mike and Brian Prestwood presenting on the Unified Modeling Language.
11 years ago, and updated 9 years ago

News
Nothing New Since Your Last Visit
3492
Hits

Icon Legend:
Recent or not:
- Recent activity (within last two weeks).
- No activity last two weeks.
 Since your last logged visit:
- New to you or updated since your last visit (sign in now to activate).
- NOT new to you since your last visit (sign in now to activate).

New Visual Basic Classic Knowledge Base Post...

Share your knowledge with the WORLD! In addition to adding comments to existing posts, you can post knowledge you've acquired. We welcome full articles (intro with screen shots), general posts (shorter), and tidbits (tips, FAQs, definitions, etc.).

Post New...

Tidbit Post: Short Flashcard FAQ Definition Quick Tip Code Snippet
Longer Post: Full Article General Post File Link Error News
Other: Blog Topic
Or, if YOU have a question...
  Visual Basic Classic Message Board
-
   Contact Us!
 
PrestwoodBoards.com was developed and is maintainted by me. Do you have a question or suggestion? Do you see a problem? Contact me now. My goal is to build an ad-free and spam-free source of I.T. information with many contributers (ok to promote your website/company in your bio). Yes, my company Prestwood IT Solutions is mentioned in my bio which shows with every post, but you can contribute and promote your pet project too!

1,715 People Online Now!!  
Sign In to see who's online now!  Not a member? Join now. It's free!
Show more stats...


©1995-2017 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech