eSiksha
 Login    Password        Sign Up   Forgot Password
Saturday, November 23, 2024


    

Site Search

 

 M.C.S.D.
 Home
 
Site Server 3 
 
Visual C 
 
Desktop Appl. 
 
Distributed Appl. 
 
Outlook 2000 
 
FrontPage 98 
 
VB6 Distributed 
 
Visual Interdev 6 
 
Win. Architecture 

 

 COMPUTERS

 Home 
 
MCSE Cert.
 
Cisco Cert. 
 
Overview 
 
The Work 
 
Areas of Work 
 
Eligibility 
 
Career Prospects 
 
Remuneration 

 

T
R
A
C
K
S
 MBA
 
Engineering
 
Medical
 
Humanities
 
Sciences
 
Computers
 
Govt. Exams
 
Commerce
 
School/+2

Designing and Implementing Desktop Applications with Visual Basic 6.0

 

Maintaining and Supporting the Application

Licensing

When you add licensing support to a control component, a license key is compiled into it. Licensing is only good for ActiveX controls.

 

To add Licensing support

  1. Go to Project Menu

  2. Click Properties

  3. Select the General Tab

  4. Check Require License Key

During the setup of your control on a client machine, the key is added to the registry. If a client has a copy of your control, but not the registry key, the component cannot create instances of itself in the development environment.

A user can run a compiled application without having the control component’s license key in the registry.

 

Interfaces

Every class has at least 1 interface called the default interface. The name of the class is preceded by an underscore, signifying that the name is hidden in the type library.

If the class raises events, it uses the interface: IConnectionPointContainer

GUIDs are automatically generated by VB that identifies your type library in the registry. A GUID is generated for each public class (called CLSID) and for each Interface ID (called IID). The CLSID and IID are used for version compatibility.

 

Compatibility

If Project Compatibility or No Compatibility is selected in Project Properties, a new CLSID and IID is generated every time you compile. Binary Compatibility does not create new GUIDs

The Implements statement allows you to add multiple interfaces to class modules.

When coding use "No Compatibility" to make a clean break.

  1. Be sure to change the name of the component so the incompatible version won’t over-write earlier versions.

  2. Change the name of the project, so the new component will have a different type library name.

Use "Project Compatibility" to simplify development, use "Binary Compatibility" for new versions of existing components.

 

Registry

Use the registry to store information like: window positions and files used. VB provides a standard registry location for applications:

HKEY_CURRENT_USER\Software\VB and VBA Program Settings\appname\section\key

 

VB uses 4 statements\functions to manipulate the registry

1. GetSetting function

Retrieves registry settings

2. SaveSetting statement

Saves or creates registry entries

3. GallAllSettings function

Returns an array containing multiply reg. entries

4. DeleteSetting statement

Deletes registry settings


Establishing the Development Environment

Creating templates

  1. Save the Object

  2. Copy it to the appropriate subdirectory of the VB Template Directory

 

Adding Controls to a Project

  1. From Project menu choose Components

  2. Select the checkbox to the left of the control name

  3. Choose OK

ActiveX controls usually have the extension .ocx. Each control is accompanied by a file with an .oca ext. This file stores type library information.

 

To add a reference to a Project

  1. From Project menu choose References

  2. Select the checkbox next to the reference you want to add

  3. Choose OK

A resource file allows you to control all of the region-specific text and bitmaps for an application.To add a resource file

  1. From Project Menu choose file

  2. Select an existing resource file(.res) and choose open

You can add new properties, methods, and events without breaking applications compiled using earlier versions; however you cannot remove members from the interface, or change the arguments of the members.

You can retain a property for backward compatibility, but stop mentioning it in your Help file, and mark it as hidden using the Procedure Attributes dialog box.

 

VSS

In VSS, files can be shared among multiple projects. Changes made to the file are automatically seen by all projects.

Branching is the process of taking a file in 2 directions. After you branch a file, the Links tab does not show the link that has been broken. Instead use the Paths tab to view the branch history of the file.

To get the latest version of a file, click Get Latest Version on the VSS menu. To get an older version, click Get in the History of File or History of Project. You must have read access rights to do this.

There are 4 outcomes to Get Latest Version

  1. If the file you are retrieving is not in your working folder, VSS just gets the file.

  2. When the file in your working folder is identical to the one your are getting, VSS does not retrieve or modify the file in any way.

  3. When the file is in your working folder and is read only, VSS replaces your local copy with the new one.

  4. When your existing file is not Read-only, VSS assumes you have the file checked out and doesn’t replace the file.

The administrator only has 2 levels of access rights to choose from for adding new uses

  1. Read-only: The use can see everything, but change nothing.

  2. Read-write: The use can see and change anything in the VSS DB.

All security is set from inside the VSS Administrator. To protect the administrator account

  1. Assign a password using Change Password command.

  2. Protect the VSS folder using the ACL of the operating system.

 

Deriving the Physical Design

Use the Property GET to get the value of property from an object:

Example: Property Get Created() as Date

Created = mdtmCreated

End property

Class modules have 2 events: Initialize and Terminate

If myObj is declared as New, it will be created the moment one of its properties or methods is invoked.

Using the End command or End Button halts execution of code, without firing the Terminate event.

ActiveX components interact through a client server relationship.

If an ActiveX component is part of a .exe, it is an out-of-process-server.

If it is a .dll it is an in-process-server.

There are 3 kinds of components that can be created:

 

Out-of-process

Advantages

  1. runs in its own stack

  2. can have asynchronous operation("threads")

  3. untrapped errors won’t cause the calling application to crash

  4. interoperability between 16 and 32bit apps

Disadvantages

  1. startup speed

  2. cross-process call overhead

 

In-process

Advantages

  1. improved load time

  2. no cross-process overhead

 

Remote

Advantages

  1. use the resources of other CPUs

Disadvantages

  1. Network overhead will exact a toll

 

Make Tab of Project Properties

Version Number

Major – Major Release number of the project 0 – 9999
Minor – Minor release number of the project 0 – 9999
Revision – Revision number of the project 0 – 9999

 

Application

Title - Name of the application
Icon – Icon for the application

 

Version Information

Type – Set values for company name, description, legal copyright, legal trademarks, product name, and comments.

 

Command Line Arguments

Allows you enter the arguments that VB sends to an app only when you choose start from the run menu.

Conditional Compilation Arguments

Allows you to enter the constant declarations used for conditional compilation.

 

DSNs

  1. File DSN. Connection information is stored as a file that can be read by any application.

  2. Machine DSN. Connection information is stored in the Registry.

If you are developing an app in C++ or J++ you can use a file or machine DSN.

If you use the Setup Wizard, you must setup a machine DSN, by modifying the registry.

 

Deploying an Application

To test component download on a development machine:

  1. Right-click the control (in either the Winnt or Windows Dir) and select REMOVE or

  2. Run regsvr32 /u mycontrol.ocx

To test support file installation, first uninstall support files by:

  1. Right-click the file and select REMOVE or

  2. Use the following command line: for %f in (*.ocx *.dll) do regsvr32 /u /s %f

To reregister support files, run: for %f in (*.ocx *.dll) do regsvr32 /s %f

 

To debug an out-of-process component

  1. Set breakpoints and watches in the class module.

  2. Run the component project by pressing CTRL-F5 or clicking START WITH FULL COMPILE.

  3. Start a second instance of VB, set any break points.

  4. Create a test application that calls the component.

  5. Run the application. If the focus is not set to the component project, click the SWITCH 0TO button.

  6. Close the test project before stopping the component project.

The only accurate way to test shutdown behavior (Terminate Event) is with a fully compiled component.

StartMode is a read-only property of the App object.

 

Package and Deployment Wizard

There are 3 ways to start the Package and Deployment Wizard.

  1. Run it from VB as an Add-in. Use the Add-in manager, from the Add-ins menu if the Package and Deployment wizard is not a pick off the menu.

  2. Run it as a stand-alone component. You will need to select the project you want to work with.

  3. Run it in silent mode from a command prompt. The name of the .exe is pdcmdln.exe. It has these arguments:

    1. /p packagingscript where packagingscript is the name of a previously saved packaging script.

    2. /d deploymentscript where deploymentscript is the name of the previously saved deployment script.

    3. /l path where path is the location into which the wizard should store all the output.

    Example

    PDCmdLn.exe C:\Project1\Project1.vbp /p "Internet Package" /d Deployment1 /l "C:\Project1\Silent Mode.log"

     

    There are 3 Options

    1. Package Option. Packages all of your project files into a .cab file, and sometimes creates a setup program to install the .cab file.

    2. Deploy Option. Delivers your packaged applications to floppies or a network share (standard package), or deliver to a web site (Internet package).

    3. Manage Scripts. Lets you view and manage scripts that are saved from previous packaging and deployment sessions. You can use scripts to deploy the app in silent mode.

    The setup package is called setup1.exe.

    To create features not supplied by the setup, modify the setup toolkit project.

     

    Internet Packages

    There are 5 types of Internet packages from VB

    1. ActiveX controls (.ocx files) displayed on a web page.

    2. ActiveX .exe or .dll designed to run on the client or webserver

    3. ActiveX documents are displayed in place of a web page.

    4. DHTML apps.

    5. IIS apps.

     

    Internet Packages contain

    1. Primary .cab file that is used as the setup program. It contains: the .exe or .dll for the app, an .ocx for controls, a .inf for referencing secondary .cabs.

    2. Support files, which can include, HTML help, graphics, and other files needed for your app.

    3. Secondary .cab files, which can contain: VB run time dll, individual ActiveX controls, data access objects. Use secondary .cabs to make sure the user has the latest components on their machine.

     

    5 steps to using the Packaging and Deployment Wizard

    1. Determine the package you want to create: Standard or Internet

    2. Determine the files you need to distribute. Both project files and dependant files. Dependent file information is stored in vb6dep.ini file or various .dep files.

    3. Determine where you want to install the files on the persons machine

    4. Create the package.

    5. Deploy the package.

    The setup program copies the application removal utility: st6unst.exe. An uninstall log file called st6unst.log is generated.

     

    The log file contains

    1. Directories Created.

    2. Files installed and their location.

    3. Registry entries created or modified.

    4. Links and start menu entries in Windows95 or Winnt40 and later.

    5. Self- registered .dll, .exe, or .ocx files.

    Shared files are set by adding the files to the Shared Files screen of the Package and Deployment Wizard or by indicating the installation location for the file as a shared directory.

    Situations that will make the application removal utility fail.

    1. The end user copied files manually.

    2. The end user deleted files rather than using the application-removal utility.

    3. Another setup program, not compliant with Win95, installs the same shared files.

    4. A shared file is installed into a different directory.

    5. The end user installs the same VB app into 2 different directories.

    6. The end user deletes st6unst.log

     

    Setup.lst

    The setup.lst file contains all the files that must be installed on the user’s machine for your application. There are 5 sections to this file:

     

    BootStrap Section

    Lists the core information about the installation, it is divided into

    1. Setup Title – The title to show in the dialog box that appears while the setup.exe is coping files to your system.

    2. SetupText – The text to show in the dialog box.

    3. CabFile – The name of the primary .cab file (or the only .cab file).

    4. Spawn – The name of the application to run after setup.exe is done, probably setup1.exe.

    5. TmpDir – Temporary dir used during installation.

    6. Uninstall – Name of the application to use as the uninstall, probably st6unst.exe.

     

    BootStrap Files

    Lists all files required by the main installation files, like the msvbvm60.dll. The setup installs these files prior to installing and launching the main installation program.

     

    Setup1 Files

    The setup program installs these files, after it installs the core files listed in the bootstrap file's section. These files include your .exe, data, text, and dependancies.

     

    Setup Section

    A list of information used by other parts of the installation process. It is divided up into:

    1. Title – The name of the application as it will appear in the splash screen during installation.

    2. DefaultDir – Default installation Dir.

    1. ForceUseDefDir – If set to 1, the app is automatically installed in DefaultDir.

    2. AppToUninstal – The name you wish to see as your app in the Add\Remove programs utility in Control Panel.

    3. AppExe – The name of the .exe.

     

    IconGroups Section

    Contains info about the Start menu program groups.

    The BootStrap Files and Setup1 Files must use the following format:

    Filex= file,install,path,register,shared,date,size[,version]

    Where:

    Filex – A keyword, where X is the file number, starting with 1 and going up.

    File – The name of the file, as it will appear on the user's computer.

    Install – The name of the file found on the distribution media.

    Path – The directory to which the file should be installed.

    Register – A registry key that indicates how the file is included in the registry.

    Shared – Specifies that the file should be installed as shared.

    Date – The last date the file was modified.

    Size – Size of the file, used to calculate setup disk space.

    Version – Optional internal version number of the file.

     

    Testing the Application

    Error Handling

    The RESUME statement returns control to the statement at which the error occurred, and attempts to re-execute that statement.

    RESUME NEXT causes the function to continue execution at the statement following the one at which the error occurred.

    Err.Raise generates a run-time error.

    Syntax: Err.Raise number, source, description, helpfile,helpcontext

    All arguments are optional except for number.

    The default property of the error object is Number.

    The Err object’s properties are reset to zero or zero length strings after an Exit Sub, Exit Function, Exit Property, or Resume Next statement.

    There are 3 error trapping options: (set by the General Tab of the Options Dialog Box)

    1. Break in Class Module

      Execution will not stop if you have an error handler written.

      Execution only stops on unhandled errors in a class module.

      This is the default VB setting.

      If no classes are written, this is the same as Break on Unhandled errors.

    2. Break on Unhandled Errors

      Only breaks on errors without error handlers.

    3. Break on All Errors

    Any error that occurs will cause the project to enter break mode.

    Turn off error handling by using ON ERROR GOTO 0 or exiting the procedure with an error Handler.

    If an error occurs in a procedure that doesn’t have an enabled error handler, VB searches backward through the procedures on the calls list, back to the initial calls event. If it doesn’t encounter an error handler, it presents a default unexpected error message and halts execution. If VB finds an error-handling routine, execution continues in that routine as if the error had occurred in the same procedure that contains the error handler.

    Use Err.clear to explicitly clear the Err object after handling an error.

     

    Debugging

    There are 3 debugging windows: Immediate, Watch and Locals

     

    Immediate Window

    Shows information from debug statements in your code, or that you request by typing into the window.

    Use to find the values of procedures, expressions, or assign new values to variables or properties.

    Examples:

    Print intX

    ?intX (will display the value of intX, the same as Print intX)

    X = Quadratic(2, 8, 8)

    DisplayGraph 50, Arr1

    Form_MouseDown 1, 0, 100, 100

    MyProcedure

    Statements can only be evaluated if they can be expressed on a single line. Use colons to separate the statements that make up a control structure.

    Use Debug.Print inside of code to display expressions in the immediate window.

    Example:

    Debug.Print "Salary="; Salary

    Use a semicolon or comma to separate 1 item from the next. A semicolon prints 1 item after another. A comma moves the item to the next tab column.

    By default the print method prints the text and moves to the next line.

    Use the STOP statement to put VB in break mode and display the Immediate window. Remove all STOP statements before you compile, or they will cause the app to end. VB treats the STOP statement as it treats END, and terminates execution without any QueryUnload or Unload events.

    Use the ASSERT statement rather than STOP. ASSERT is automatically removed when the application is compiled. ASSERT conditionally suspends execution at the line on which the method occurs.

    It is possible to display values for objects, regardless of scope, if the fully qualified object name is provided.

    Example: Form1.text1.value

     

    Watch

    Shows watch expressions are expressions whose values you decide to monitor as the code runs. A break expression is a watch expression that will cause VB to enter bread mode when a certain condition becomes TRUE.

    Only displays values that are in context.

    Drag a variable into the watch window or immediate window to see its value.

    If the context of the expression isn’t in scope, the current value isn’t displayed.

    To add a watch expression, use the Add Watch Dialog Box. Set the following values:

    Expression Box – Enter the expression the watch expression evaluates. Either a variable, property, function call or any valid expression.

    Context Option Group – Sets the scope of the watch by Procedure and or module. Can also set it to All Procedures and All Modules.

    Watch Type Group – Set with one of three values: Watch Expression, Break when Value is true, Break when value changes.

    To edit or delete a watch, double click the expression in the watch window.

     

    Locals

    The values of any variables within the scope of the current procedure.

    To debug in process components, load 2 or more projects into a project group.

    When you set a breakpoint, VB halts just before executing that line of code.

    Conditional Compilation lets you selectively compile certain parts of the program. To conditionally compile a part of code, enclose it between #if… then and #endif statements, using a Boolean test.

     

    There are 3 ways to declare conditional compilation constants

    1. Project Properties Dialog box.

    2. Setting Constants on a command line.

      Example: vb6.exe /make MyProj.vbp /d conFrenchVersion=–1:conANSI=0

    3. Use #const statement in code.

    The call stack displays all functions on the stack that have started, but not completed. It places the earliest active procedure call at the bottom.

    The call stack is only visible in break mode.

    Because a project group can contain multiple projects, VB needs to know which project to execute first. To specify a project, right-click the project and select SET AS START UP.

     

    Compiling

    P-code is an intermediate step between the high-level instructions in VB and the low level native-code of the computer’s processor.

    Native Code can be debugged using C++ tools.

    Native code takes advantage of the processor, however, you still need the MSVBVB60.DLL. Native code provides the following options

    1. Assume No Aliasing – Tells the computer to apply optimization such as storing variables I registers

    2. Create Symbolic Debug Info – Allows debugging with VC++5.0 or compatible debugger.

    3. Favor Pentium Pro – Optimizes code for the Pentium Pro.

    4. No Optimization – Disables all optimizations.

    5. Optimize for Fast Code – Favor code speed over size.

    6. Optimize for Small Code – Favor code size over speed.

    7. Remove Array Bounds Checks – Disables array bounds checking.

    8. Remove Floating Point Error – Disables floating-point error checking.

    9. Remove Integer Overflow Checks – Disables overflow checking.

    10. Remove Safe Pentium FDIV Checks – Disables checking for safe Pentium processor floating point division.

     

    LogEvent method

    Logs an event in the application’s log target. On NT, the method writes to the NT Event Log. On Win95 the method writes to the file specified in the LogPath property. By default the file name is vbevents.log

    Syntax: Object.LogEvent(logBuffer,eventType)

     

    Creating User Services

    User Objects, their methods, their properties

     

    ActiveControl Property

    Returns the control that has the focus. Each form can have an active control, regardless of whether or not the form is active.

     

    Add Method (Tabs Collection)

    Adds a Tab object to the Tabs collection in a TabStrip control.

    Returns a reference to a newly inserted Tab Object

    Syntax: objTab.Add(index,key,caption,image)

    Index - optional - an int specifying the position where you want to insert the Tab.

    Key - optional - a unique string that identifies the Tab.

    Caption - optional - the string that appears on the tab.

    Image - optional - the index of an image in an associated ImageList control.

     

    AddItem Method(ListBox or ComboBox)

    Adds an items to a Listbox or ComboxBox

    A ListBox or ComboBox that is bound to a Data control doesn’t support the AddItem method.

    Syntax: object.AddItem item, index

    Item – required – a string expression specifying the item to add to the object.

    Index – optional – Int specifying the position within the object where the new item or row is placed.

     

    ButtonClick

    This Event occurs when the user clicks a Button object in a ToolBar control.

     

    Click Event

    Occurs when the user presses and releases a mouse button over an object. Also occurs when the value of a control is changed.

    To distinguish between left, right, and middle mouse buttons, use the MouseDown and MouseUp events.

    You can trigger a Click Event in code by:

    Setting a CommandButton controls Value property to TRUE

    Setting an OptionButon control’s VALUE property to TRUE

    Changing a CheckBox control’s Value property setting.

     

    Control Array

    A control array is a group of controls that share the same name and type. The maximum index in a control array is 32767. Adding controls using a control array uses fewer resources than simply adding new controls. To add or remove a control in a control array at run time use Load and Unload statements.

    Settings are copied from the lowest existing element in the array.

    You cannot Unload controls created at design time.

    Syntax: Load object(index%)

    Object – name of the control to add.

    Index% - The index value in the array

     

    Dim

    Declares variables and allocates storage space.

    If you do not specify a data type or object type, the variable is Variant by default.

    A numeric variable is initialized to 0.

    A string is initialized to a zero-length string.

    A fixed length string is filled with spaces.

    Variants are initialized to empty.

     

    DragOver Event

    Occurs when a Drag-and-Drop operation is in progress

    If the source control is dropped on the object, that object receives a DragDrop event.

    Syntax: Private Sub object_DragOver([index As Integer,]source As Control, x As Single, y As Single, state As Integer)

    Index – Used to reference an object in a control array.

    Source – The control being dragged.

    X,Y – Position of the mouse pointer.

    State – The transition state of the control being dragged. One of: Enter, Leave, Over.

     

    Form

    Caption property: the text that is shown in the form’s title bar.

    Icon property: the icon that is displayed when the form is minimized.

    Left property: the location in relation to the left side of the screen.

    Top property: the location in relation to the top of the screen.

    Name property: sets the name used in the code.

    Resize event: triggered by resizing the form by using the mouse or by code.

    Activate event: triggered by the form becoming the active form.

    Deactivate event: triggered when another form or application becomes active.

    Show method: the same as setting the form’s Visible property to true.

    A form goes through 4 states

    1. Created, but not loaded. This is the only state all forms pass through.

      Marked by the Initialize event. The form exists as an object, but has no window.

      Example: Set frm = New Form1.

    2. Loaded, but not shown. Marked by the Load event.

    3. Shown - The form becomes visible.

    4. Member and resources completely reclaimed. Marked by the terminate event.

    Example: Set frm = Nothing

     

    GoBack Method

    Execute a hyperlink jump back in the history list.

     

    Help

    The HelpFile property of the App object is used to specify the name of the help file. Must be .hlp or .chm.

    The Err Object also has a HelpFile property.

    The HelpContextID property is used to link a user interface element to a related topic in a help file.

    To assign a HelpContextID:

    1. Select the control or form.

    2. Double-click the HelpContextID in the properties window and enter a Long Int.

     

    Index Property (control array)

    Returns or sets the number that uniquely identifies a control in a control array.

    Syntax: object(number).Index

     

    KeyPress

    The KeyPress event can process a double-bye character code as one event.

    Example: Private Sub Form_KeyPress(keyascii as Integer)

    Convert the keyascii argument into a character by using Chr(keyascii)

    Use Asc(char) to convert back to keyascii.

    KeyPress interprets A and a differently

    KeyDown and KeyUp view A and a as the same.

    If KeyPreview is set to True, the form receives the event before the controls on the form receive the event.

     

    ListBox Control

    If no item is selected, the ListIndex property value is –1. The first item in the list is 0. The value of ListCount property is always one more than the largest ListIndex value.

    Use AddItem or RemoveItem to add or remove items.

     

    ListView Control

    There are 4 different views

    1. Icon – Allows the user to drag and drop icons.

    2. Small Icon – Allows more ListItem objects to be viewed.

    3. List – Presents a sorted list of items.

    4. Report – Presents a sorted view with SubItems allowing extra information to be displayed.

     

    NavigateTo

    A method executes a hyperlink jump to a specified target. If the container supports OLE hyperlinking, it will jump to the location, else the registered application that supports hyperlinking will handle the request.

     

    Pop-up Menus

    Any menu that has at least one menu item can be displayed at run time as a pop-up menu.

    Syntax: [object.]PopupMenu menuname [, flags [,x [, y [, boldcommand ]]]]

    Only 1 Menu can be displayed at a time.

    Flags – vbPopupMenuLeftAlign. – The specified x location defines the left edge of the popUp menu.

    VbPopupMenuCenterAlign – the pop-up menu is centered around the specified x location.

    VbPopupMenuRightAlign – The specified x location defines the right edge of the pop-up menu.

     

    ProgressBar Control

    Set the visible property to True to show the control at the start of an operation, and visible=false at the end of an operation.

     

    PUBLIC

    This statement is used at Module level to declare variables and allocate storage space. A PUBLIC statement cannot be used in a class module to declare a fixed length string.

     

    QueryUnload

    The QueryUnload Event occurs before a Form or Application closes. The event is used to make sure there are no unfinished tasks in the forms included in an application before the Application closes. If you use the End statement of the End button, this event does not fire.

     

    Sorted Property

    Returns a value indicating whether the elements of a control are automatically sorted alphabetically.

     

    StatusBar

    A panels collection contains a collection of Panel objects. The collection is a 1-Based array.

    Syntax: statusbar.Panels(index)

    The Panels property returns a reference to a Panels collection.

    The PanelDblClick event occurs when someone double-clicks the panel.

    The Style property sets the style of a StatusBar control’s Panel object. The StatusBar can toggle between two modes: Normal and Simple.

     

    TabIndex property

    Returns or sets the tab order of most objects within their parent form. If you delete an object, you can Undo the delete; however, the TabIndex property is not restored, it is reset to the end of the tab order when you use Undo.

     

    ToolTip property

    Returns or sets a ToolTip.

    Syntax: object.Tooltip [= string]

    For a Toolbar and TabStip control, you must set the ShowTips property to True to display ToolTips.

     

    TreeView

    The Add method adds a Node object to a Treeview control’s Nodes collection. The collection is 1-Based.

    Syntax: object.Add(relative, relationship, key, text, image, selectedimage) Returns a reference to a newly created node object.

    Example: tvwMytree.nodes.add "7 node", tvwChild, "11 node"

    Relative – Optional -the index number or key of a pre-existing node, position is determined by relationship.

    Relationship – Optional -Specifies relative placement of the node object.

    TvwFirst – The node is placed before all other nodes, at the same level as the node in relative.

    TvwLast – The node is placed last, as the same level as the node in relative.

    Tvwnext – The node is placed after the relative node.

    TvwPrevious – The node is placed before the relative node.

    TvwChild – The node become a child of the relative node.

    Key - Optional - A unique string though out the collection.

    Text – Required - String that appears in the node.

    Image – Optional – Index of an image in the ImageList control

    Selectedimage – optional – the index of the image in the ImageList control when the node is selected.

    When node is added, it is assigned an index number.

    ObjTreeView.Nodes.Item(index) refers to a node object in a TreeView. Index is an int or a string that uniquely identifies a member of a nodes collection. The int is a value of the Index property, the string is a value of the Key property.

     

    TypeName

    Returns the class name as a string.

     

    TypeOf

    Can only be used in If…Then…. Else statements.

    Syntax: If TypeOf MyControl is Checkbox then….

     

    Unload Event

    The Unload event is fired after the QueryUnload event. When a form is unloaded, all controls placed on the form at run time are no longer accessible. Controls placed on the form at design time remain intact. All changes to the form properties are also lost. Accessing any controls on the form causes it to be reloaded.

     

    WhatsThisHelp

    Setting the WhatsThisHelp property of a form to True enables What’s This Help, however, context sensitive help for the form is disabled. Must be contained in a Cshelp.text file that is compiled into the .chm file.

    Set the following properties to add a what’s This button to the title bar of the form.

    BorderStyle 1-Fixed Single or 2 – Sizable

    MaxButton False

    MinButton False

    WhatsThisButton True

     

    Coding

    Passing by reference is default in VB.

    Use the Optional keyword in an arguments list to specify an optional argument. When optional arguments are not provided, the argument is actually assigned as a variant with the value of Empty.

    The ParamArray keyword allows you to specify that a procedure will accept an arbitrary number of arguments.

    You can use the syntax MyArgument:="Some Value" to pass values into a procedure.

    You can make an ActiveX control without a user interface, but it should normally be visible. If you need an invisible control, consider writing an automation server with event support. A timer control is an example of an invisible ActiveX control.

     

    Code Editor

    There are 2 different views in the code editor. One version allows you to view a single procedure, the other version allows you to view all the procedures.

    Bookmarks can be used to mark lines of code in the code editor.

     

    Creating and Managing COM Components

    Friend

    When a method is declared with the Friend keyword, it’s visible to other objects in your component, but is not added to the type library or the public interface.

    Example: Private msoc as new Socket

    Friend Property Get Socket() as Socket

    Set Socket = msoc

    End Property

     

    Apartment Threading

    Is used to provide thread safety and works by giving each apartment its own copy of global data.

    You cannot us global data to communicate between objects on different threads. However, objects in different apartments can communicate if a client passes references to them.

    All components in VB use the apartment model.

    A multithreaded in-process component has no threads of it’s own, they each belong to the client.

    A multithreaded out-of-process component may have a thread pool with a fixed number of threads.

    For DLLs and ActiveX controls, select either Apartment threaded or single threaded.

    For ActiveX EXEs, specify that each new object is created on a new thread, or a fixed thread pool.

    To Set Unattended Execution (allow components to run without operator intervention)

    1. Project Properties

    2. On General Tab, check Unattended Execution.

     

    Limitations

    The Development environment doesn’t support multithreaded debugging.

    MDI Forms are not allowed in apartment – threaded projects.

    Friend Properties and Methods can only be called by objects on the same thread.

    ActiveX Docs in ActiveX EXE projects will not be apartment-model thread-safe unless you select Thread Per Object or Thread Pool.

    When a thread shows a vbModal form, the form is only modal to the code and forms on that thread.

    It is possible to trick VB into using a single-threaded control in an apartment-threaded project by manually editing the .vbp file. DO NOT DO THIS.

    A collection is an object that contains a set number of related objects.

    For only a client to create an object set Instancing to PublicNotCreatable.

    To make objects externally creatable, set the Instancing property to MultiUse.

    Objects that are creatable and dependent should be designed to require no initialization beyond their Initialize events.

    DLLs run in the same process as your Application.

    ActiveX EXEs usually run in an out-of-process server.

    Here are some guidelines:

    ActiveX-enabled Application Out-of-Process

    Code Component Either In-process or Out-of-process

    ActiveX control In-process

    ActiveX document Either in-process or out-of-process

    To declare a new object use: Dim myObj as New Worksheet.

    VB will automatically create the new object the first time you use the variable.

    Use: Set myObj = Create("progID",["servername"]) to assign an object reference to a new variable

    Use: Set myObj = GetObject([pathname][,progID]) to assign an object reference to an existing object

    Use the Add Annotation Dialog box to enter textual annotations or comments to a component’s properties.

     

    Create an AboutBox

    1. Create a form that will contain the About information.

    2. Create a Sub that will show the box, vbModal, and unload it.

    3. On the Tools menu, click Procedure Attributes, in the Name box, click the drop down and select it.

    4. In the Procedure ID, select AboutBox to give the procedure the correct identify

    Compiling a component automatically registers it as an Add In. To register a DLL (in-process component) use regsvr32.exe. To register an out-of-process component add the /regserver parameter to the .EXEs file’s command line.

    Optimize Objects by using

    1. Early binding.

    2. Minimize the dots.

    3. Use Set and With…End With.

    4. Minimize cross-process calls.

    An ActiveX doc is composed of a UserDoc, Code, Code Module, and Controls. The .dob file contains the source code and property values. The .dox contains the graphical elements that cannot be stored as plain text. .dox are equivalent to .frx

    A compiled ActiveX doc will be an .EXE or a .DLL and will have an accompanying .vdb, which IE will open. The .vbd will be placed in the same directory as the .exe or .dll. Use the NavigateTo method to move to different ActiveX docs.

    Example: Private Sub cmdGoNext_Click()

    UserDocument.hyperlink.NavigateTo "c:\myDocObject1.vbd"

    End Sub

    The properties and methods of a class make up its default interface. The following names cannot be used a property or method names:

    IUnknown, IDispatch, QueryInterface, AddRef, Release, GetTypeInfoCount, GetTypeInfo, GetIDsOfNames, and Invoke.

    Data hiding is the ability of a project to protect part of an objects data.

    Property procedures allow an object to protect and validate its own data.

    To Test a component you need to create a client application. Test for both functionality and error cases. Create a generic application that tests each element of the objects interface.

    The test project must be an EXE. Usually make your project a standard EXE, however, to test call backs, use an ActiveX EXE, so it can include public classes that implement call back methods.

    ActiveX Documents cannot be debugged without a browser.

    Use the Procedure Attributes dialog box to enter description strings for your properties, methods, events, and to provide lines to topics in your help file. Users can view these descriptions using the Object Browsers. The Object Browser can also be used to enter this information.

    To enter these descriptions using the Procedure Attributes Box

    1. Open a code window of the project.

    2. On the tools menu, click Procedure Attributes.

    3. Select a property name, method, or event in the Name box.

    4. Enter the HelpContextID.

    5. Enter a Description.

    6. Click Apply.

    You cannot supply help topics or browser strings for enumerations.

     

    Instancing

    Determines whether your class is Private or available for other applications. It also determines how other applications create instances of the class. Instancing can have

    1. Private – Other applications aren’t allowed access to the type library. Only for use within your own component.

    2. PublicNotCreateable – Other applications can use objects of this class, only if your component creates the objects first. Cannot use CreateObject or New operators with this instance.

    3. MultiUse – Allows other applications to create objects from the class. One instance can provide any number of objects.

    4. GlobalMultiUse – Like MultiUse, plus, properties and methods can be invoked if they were global functions without explicitly creating an instance of the class first.

    5. SingleUse – Allows other applications to create objects from the class, but every object states a new instance of the component.

    6. GlobalSingleUse – Like GlobalMultiUse, except SingleUse instead.

    Use the following table for projects

    Instancing Value

    ActiveX EXE

    ActiveX DLL

    ActiveX Control

    Private

    Yes

    Yes

    Yes

    PublicNotCreateable

    Yes

    Yes

    Yes

    MultiUse

    Yes

    Yes

     

    GlobalMultiUse

    Yes

    Yes

     

    SingleUse

    Yes

     

     

    GlobalSingleUse

    Yes

     

     

    The Object Browser displays the classes, properties, methods, events and constants available from object libraries, and the procedures in your project.

    By default the properties of the UserControl object, and the constituent controls you add to it, are not visible to the end user of the control.

    To expose a property, expose the property of the constituent control.

    Example of the BackColor property: Public Property Get BackColor() as OLE_COLOR

    BackColor = txtBox.BackColor

    End Property

    To Map properties to multiple controls use a For Each loop and check the TypeOf object.

     

    Microsoft Transaction Server (MTS)

    By Default, MTS does not have any users mapped to the administrator role, that means, anyone with an account can modify package configuration on the computer. By default there are 2 roles, the Administrator Role, and a Reader Role. Administrators can do anything, Readers cannot install, create, change, or delete objects, shut down server processes, or export packages. They can view all objects in the MTS Explorer hierarchy.

     

    Visual Component Manager (VCM)

    VCM handles publishing, finding, and reusing components.

    It is a single source to organize, find, and insert components into your project.

     

    Publishing

    Publishing means storing it in a Visual Component Manger database, this can be MS Access or SQL Server. This provides a single source for anything that can be added to a MS Visual Studio project. In addition to components, VCM can also store component libraries, templates, models, and complete application frameworks.

     

    Finding

    Finding provides a flexible keyword and search mechanism to help organize and cross-reference components .

     

    Reuse

    To reuse a component, click Add to my project on the component’s shortcut menu.

     

    Asynchronous Processing

    There are 2 parts to Asynchronous processing: the first part is the responsibility of the author, the second part is the responsibility of the developer who uses the component.

    The Author must

    1. Define the tasks or notifications to be performed.

    2. Provide 1 or more externally creatable classes to manage the tasks.

    3. Provide a manager class with methods that clients can call to initiate tasks or to request notifications.

    4. Declare the events that clients must handle in order to receive notifications.

    5. Write code to start the task or the process or watching for interesting occurrences.

    6. Write code to raise the event when the task is complete, or when occurrences are observed.

    The Developer must

    1. Create a WithEvents variable to contain a reference to the object that will provide the notification events.

    2. In the event procedures, write the code to handle the notification events.

    3. Write the code to request an instance of the component’s manager class and place the reference to it in the WithEvents variable.

    4. Write code to call the methods that initiate tasks or that request notifications.

    A single event can be handled by multiple clients.

     

    Call Back Methods

    The Developer must

    1. Create a public class that implements the interface defined by the component author.

    2. In the call-back methods the client will use, write the code to handle the notifications. All the methods of an interface must be implemented.

    3. Write code to request an instance of the manager class.

    4. Write code to call the methods that initiate tasks or request notifications.

     

    Creating Data Services

    Indexed Sequential Access Method (ISAM) file applications commonly process each record one by one, to the end of the file.

    Objects, Methods, Properties, Events of ADO:

     

    Recordset

    Can be thought of as an Array of Rows.

    The state property for a Recordset executing an asynchronous method whether the state is connecting, executing, or fetching, or closed.

     

    InfoMessage (ConnectionEvent)method

    Called whenever a warning occurs during a ConnectionEvent operation.

    Syntax: InfoMessage pError,adStatus, pConnection.

    There are 2 families of events: ConnectionEvent (Connection Object) and RecordsetEvent(Recordset Events). Events called before an operation usually have the naming convention WillEvent . Events called after an operation concludes usually have the naming convention EventComplete.

     

    Execute Method (Connection Object)

    Executes a query, SQL Statement, stored procedure, or provider-specific text.

    For a row returning recordset, a recordset object reference is returned. The recordset is always a read-only and forward-only cursor.

    If an error occurs in ADO, error objects are placed in the Errors collection of the Connection Object. The error object represents a specific provider error, not an ADO error. The SQLState and NativeError properties, of the Error Object provide information from the SQL Data sources. Use the Clear Method to clear the Errors Collection.

     

    ADO Data Control

    The ADO Data Control is used to create connections between data-bound control and data providers.

    4 Uses of the control

    1. Connect to a local or remote database

    2. Open a table or SQL Statement, or Stored Procedure

    3. Pass data field values to data-bound controls

    4. Add\Update Records in the database.

    The control is inefficient and requires 2 connections to the database for the first control, and 1 connection for every control afterwards. To connect to a data source, you will need to specify one of the following: a connection string, a .UDL file, or a DSN.

    The Recordset property sets a recordset object defined by a Data control’s properties. The type of Recordset is determined by the Type property. The records of the recordset can be determined by moving to the last record in the recordset and examining the RecordCount property. The DataControl doesn’t support forward-only Recordset Objects.

    The validate event of the Data Control occurs before a different record becomes the current record, before the UPDATE method, before a Delete, Unload, or Close Operation.

    Some other Events of the ADO Data Control

    WillMove On Recorset.open, any record move, Recordset.Requery, Recordset.Resync

    MoveComplete After WillMove

    WillChangeField Before the Value Property Changes

    FieldChangeComplete After WillChangeField

    WillChangeRecord On Recordset.Update, .Delete,.CancelUpdate,.UpdateBatch, .CancelBatch

    RecordsetChangecComplete After WillChangeRecordset

    InfoMessage When the data provider returns a result.

     

    Cursors

    To Optimize Cursors..

    • Use Cursors only when you need to.

    • Load the cursor immediately by moving to the last row. This releases the share locks taken when the cursor was built.

    • Use client-side cursors appropriately.

    • Use batch cursors.

    • Fetch a smaller result set.

    • Use multiple result sets.

    • Submit multiple queries as one.

    • Execute queries asynchronously by using Microsoft Message Queue Server.

    • Use transactions.

    • Use page-level locking.

    • Use the minimum lock.

    • Use off-hours for bulk operations.

    The default cursor, forward-only, can only move forward through the result set and does not support scrolling. After data for the current row is processed, the cursor releases the resources that were used to hold the data. Forward-only cursors are dynamic because all changes are detected as the current row is processed.

     

    4 ADO Cursors

    1. Forward-only

    2. Keyset

    3. Dynamic

    4. Static

     

    4 Locking Options

    1. Pessimistic concurrency.

    2. Optimistic concurrency using row values.

    3. Read-only. Changes are not permitted.

    4. LockBatchOptimistic – Updates are deferred until the batch update is finished. Need keyset or static cursor.

    The CursorLocation property returns the location of the cursor engine. Can be adUseClient or adUseServer. AdUseNone is solely for the sake of backward compatibility.

     

    To Create a Master/Detail Form

    1. Create a parent/child data environment command object.

    1. Create a command object the Data Environment.

    2. Define its SQL Statement.

    3. Add a child command by right-click on the parent command in the Data Environment designer, then select Add Child Command, from the popup Menu.

    4. Define the SQL Statements for the child command object.

    5. Define the Parent-Child relationship by clicking the properties of the child command, select Relation tab, and define the relationship between the Parent and Child Fields.

    1. Drag the Command object from the Data Environment designer to a blank form.

     

    To Create a Data Report

    1. Create a new standard.exe.

    2. Add a Data environment.

    3. In the connection properties, select the correct OLE DB provider and connection.

    4. Create a Command Object.

    5. Set the Command Name, Connection, and DataSource.

    6. Add a Data Report.

    7. In the Data Report properties, set the DataSource and DataMember.

    8. Right click the Data Report designer, click Retrieve Structure.

    9. From the Data Environment, drag the fields you want on the report.

    10. If there isn’t a form in the project, add one.

    11. Add a command button, to the command_click sub, and add the syntax: reportname.show.



     
    Home | Abroad | Academics | Advice | Alumni Associations | Career Watch | Competitive Exams | Career Counseling | Distance Education | Forms | Organisations | Relax Zone | MBA | Engineering | Medical | Humanities | Sciences | Computers ICSE/ISC/CBSE | Scholarship | Loans
     
     Contact Us | Feedback | Advertise | Disclaimer | Privacy Policy
     
    ©2000-2001 All rights reserved "DD Web Vision Private Limited"

    Site developed by