Search
Left Quote    If at first you don't succeed, redefine success.
- Anon.    
Right Quote
 
[login] | [Register]
 

Getting Started with VB 6.0

by: bs0d
Page: 6 of 9
(View All)

Sub Procedures, Random Numbers


Procedure - A unit of code that performs a specific task and can be called from other locations of the program.


PURPOSES OF PROCEDURES:


  • Break large sections of code into smaller units of code that perform a specific task.
  • Makes it easier to debug and maintain program.
  • Cuts down on the amount of code that has to be written, and eliminates duplication of code.

TYPES OF PROCEDURES:


Sub Procedure - A procedure that performs a task but DOES NOT return values back to the calling module.

Function Procedure - A procedure that performs a task and RETURNS a value back to the calling module. With function procedures, the value is returned back to the calling module using the function name.


CREATING A NEW SUB PROCEDURE:


  1. Display the code window for the form
  2. Select ADD PROCEDURE from the TOOLS menu
  3. Enter the name of the procedure in the text box next to where it says NAME
  4. Select PRIVATE for SCOPE
  5. Click OK
  6. You will be given the procedure shell. Type in the contents of your procedure
  7. Click on the code button to exit the procedure

Example of a Sub Procedure:


Example of a Sub Procedure Call:


Example of a Function Procedure:


Example of a Function Procedure Call:


WITH STATEMENT


The WITH keyword allows you to cut down on coding when dealing with properties of controls.


Syntax of WITH statement:

With < control >
.< property1> = < value1 >
.< property2> = < value2 >
.< property3> = < value3 >
End With

Assigning controls without the WITH KEYWORD:


Assigning controls using the WITH KEYWORD:


COMMON DIALOG CONTROL


Allows your project to use the dialog boxes that are provided as part of the Windows environment to set properties for a control such as font, font size and color.


FEATURES OF THE DIALOG CONTROL:


  • You only need common dialog control on your form
  • You cannot change the controls size
  • The location of the control does NOT matter
  • The control will be invisible when the program runs
  • Dialog controls are stored with an extension of .ocx
  • When naming Dialog controls, begin with a prefix of dlg
  • The common dialog box may not appear in your toolbox. It is a custom * control and will need to be added to your project before you can use it.

RETRIEVING THE COMMON DIALOG CONTROL:


  1. Click on Project
  2. Click on Components
  3. Scroll down and find Microsoft Common Dialog Control 6.0
  4. Click the check box next to it to select it.
  5. Click OK and it will be placed in your tool box.
  6. Click on Dialog Control and place it on your form.

CHANGING FONTS:


Example Syntax for Setting Fonts:

With dlgCommon (assuming that you named it that)
.Flags = cdlCFScreenFonts

1  |  2  |  3  |  4  |  5  |  6  |  7  |  8  |  9  |  
Next »


No Comments for this page.

You Must be logged in or a member to comment.


Tutorial Stats

Tutorial Stats

129,660 Views
0 Total Comments
4.16 Rating of 5 (6 Votes)

Options

Tutorial Options

· Login to Rate This Article
· Login to Post a Comment
· Read more by this author
Digg This Article! Del.icio.us: Bookmark This Article Reddit: Bookmark This Article BlinkList: Blink This Article! YahooMyWeb BlogMarks: Add This Mark! Furl: Save This Article Spurl: Mark This Article

Articles

Related    

· Coding a Webserver
· Using Crystal Reports in VB
Your Article Here


"AllSyntax.com" Copyright © 2002-2014; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank