Fundamentals of Visual Basic / PDF
Fundamentals of Visual Basic / PDF
Variables
String à numeric value
Numeric value à string
Declaring variables explicitly (optional)
WHERE should variables be declared?
Indicating variable type in the variable names (optional)
Using variables
Private vs. public variables
What is the different between public and global variables?
Table of Contents
Fundamental facts
Kinds of modules
Visual Basic files
Visual Basic vs. VBA
How to insert new stuff
Variables
String à numeric value
Numeric value à string
Declaring variables explicitly (optional)
WHERE should variables be declared?
Indicating variable type in the variable names (optional)
Using variables
Private vs. public variables
What is the different between public and global variables?
Learning about objects with the Object Browser
Leftover notes
Creating a desktop shortcut
Creating applications
Setting the starting place for a new form
Using variables and procedures in multiple forms and event procedures
Creating menus
Creating nonstandard menus
Common dialog objects
DriveListBox, DirListBox and FileListBox controls
I/O controls
Radio buttons
Input boxes
Message boxes
Combo boxes
Creating nonstandard dialog boxes
Loading and unloading forms during runtime
Setting the properties of windows
Modal, nonmodal
Minimizing, maximizing
Parent and child windows
Various notes on creating applications
Creating the user interface: windows
Declaring arrays
Creating an executable file
Using an OLE object to launch applications
Viewing an Access DB
Using the ADO Data Control and DataGrid Control
Second method
Loops and decision structures
Existing a loop
Programming technique
Image Box
Branching back from a GoTo destination
Enabling Drag and Drop
Something is to occur even in the absence of any event
Events occur for a certain time span
Running a DIFFERENT event procedure while some event is being processed
Calling another procedure from within an event procedure
Start an application without automatically showing a specific form
A control covers the entire area of a form
Width vs. ScaleWidth, Height vs. ScaleHeight
Interpreting and using keypresses
The event procedures of what objects can be used to trap keypresses?
Using the Form_KeyDown(), Form_KeyUp(), and Form_KeyPress() procedures
Using text
Make the text box cover the entire form area
Displaying text in a text box
Displaying text in a form
Displaying text in a picture box
Print/display formatting
Displaying table columns
Formatting text in a text box
Setting font size in a text box
Setting font name in a text box
Accessing a specific font
Using the Clipboard
Properties for manipulating text marked by the user
Clearing the clipboard
Sending text to the clipboard Ctrl + C
Sending text box text to the Clipboard
Sending combo box text to the Clipboard
Sending list box text to the Clipboard
Sending picture box images to the Clipboard
Cutting text Ctrl + X
Deleting text box text
Deleting combo box text
Deleting list box text
Deleting picture box images
Pasting text Ctrl + V
Pasting text to a text box
Pasting text to a combo box
Pasting text to a picture box
Pasting text to a list box
Determining what kind of stuff is currently in the clipboard
Printing
Printing a form
High-resolution printing
Printing a text string
Printing any text
Interesting Printer properties
Graphics
Easiest way to quickly move shapes around the screen
Programming artwork
Clear an image
When the programming calculates a new position for an object, when is the object repainted (moved)?
Refreshing the screen with the Refresh method
CurrentX, CurrentY
Specifying relative position
What is the difference between Width and ScaleWidth, Height and ScaleHeight?
Obtaining the color of a given pixel
FillStyle, FillColor
Horizontal and vertical scroll bars
Debugging
Program command equivalent to pressing the Break button
Frills, neat stuff
Allowing access to command buttons with the Tab key
Allowing access to command buttons with Alt + some key
Creating an application icon
Spelling dictionaries, detecting a document's language
Active spelling dictionaries
Custom dictionaries
A document's language
Reading text files, with the FileSystemObject
Important concepts
Basic procedure
Creating a text file
Opening a text file
Writing to a text file
Closing an open file
Reading from a text file
Writing and then reading, etc.
VBScript
Basics
Adding an ActiveX Control to a page in FrontPage
Viewing or modifying control properties
Programming techniques
Accessing objects
Accessing a single object in an array kind of way
Accessing a single object by its name
Accessing an entire collection of objects
Working with multiple forms
Setting the contents of the browser's status bar
Clicking on a button evokes a hyperlink
Appendix
Visual Basic Web sites
Reds
Scrawlings
Arbitrary text
ListFonts
Creating game screens with fonts and VB graphics
**********************
Sample of the pdf document
How to insert new stuff
In Visual Basic, select the Tools menu.
There, select Macros.
Select a macro.
Click on the Edit button.
You will see the current macro code in the Code window.
Modify it as you want.
Click on Run Sub.
Variables
Data types: Halvorson, p. 130
Naming conventions: Halvorson, p. 261
It is not true that all VB variables default to the string type. However, note the following:
Any time your application receives user input from an input box, that input is always automatically a string. You must use Val if you want to have numeric values.
Also, label captions must be strings. Anything else results in a type mismatch error.
String values are assigned to variables like this:
LastName = "Jefferson"
not LastName = Jefferson
See Halvorson, p. 121, the code at item 6
Salary = 5000
Salary is a number and can be directly manipulated mathematically.
String à numeric value
Use the function Val
Example: Halvorson, p. 137 – 8, application \Vb6Sbs\Less05\BasicOp
Input à mathematical manipulation
Any time your application receives user input from a text box, that input is always automatically a string. You must use Val if you want to have numeric values.
Do not confuse Val with the Asc function. The latter converts an ASCII character into the corresponding integer.
Numeric value à string
Use the function Str
Mathematical manipulation à output
The obvious use: You have done a lot of mathematical manipulations. In order to display the result in a label, with the caption property, you must first convert the number result to a string.
Do not confuse Str with the Chr function. The latter converts an integer into the corresponding ASCII character.
Declaring variables explicitly (optional)
Use the Dim statement.
Dim Interest%
or
Dim Intest as Boolean …
The specification of variable type (such as %) is optional. If you specifiy no variable type (simply Dim Interest), the variant type is used by default.
The variable types are listed in Halvorson, p. 130.
You can force yourself to always make explicit variable type specifications. Halvorson describes how on p. 120.
WHERE should variables be declared?
Variables for all procedures (public variables) must be declared in a standard module (=General/Declarations). See Halvorson, Lesson 10.
Variables for only one procedure (local variables) are declared within that procedure.
Indicating variable type in the variable names (optional)
· Use the symbols on p. 130 in the table's Sample usage column. Example:
· Or add a prefix to the variable name, such as strName, if Name is a string variable.
Using variables
For a good example, refer to \Vb6Sbs\Less05\Data. This app is discussed in Halvorson, p. 132.
Private vs. public variables
Standard modules contain public variables, used in multiple procedures. Refer to Halvorson, Ch. 10.
Halvorson provides an example of private variables on p. 132.
What is the different between public and global variables?
Declaring the ggFlag variable means that this variable is visible by all procedures in all modules and forms:
Global ggFlag As Integer...........
Fundamentals of Visual Basic / PDF
0 commentaires: