Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

This document describes the procedures and utilities for building real time Web based graphic screens under Visual Basic 6.0.  These screens may be animated using real time data from a control system.  Screens may be displayed on any workstation using a browser such as Microsoft Internet Explorer 5.5.

This document describes the basic procedures for building and publishing a screen.  An overview of the process is as follows:

  •  Use Microsoft Visual Basic 6.0 to build the basic screen

  • Animate the screen using the provided real-time objects

  • Publish the screen to the proper control system, making it accessible via the web from any network connected Internet browser

  • Install and configure the proper utilities on the control system to provide access to process variables

  • Display the page on a workstation using Microsoft’s Internet Explorer


Naming Conventions

 ...

Object Name

How to Name

Prefix

Example

Vector Project

The previous name of the screen under the Vector system.  Not to be changed.  (Not used in OPC system)

None

3Main

OPC Project directory

Created when new screen is generated through the tpriNtRt administrator program. Directory needs to be renamed without the mill site abbreviation.  In this case, the ‘l’ prefix was moved from the directory name.

None

\3Main\

OPC Project

Automatically created with appropriate prefix. The file will have a .vbp extension*

l

l3Main

OCX Control

(that you are building)

Automatically created with appropriate prefix.  The file will have a .ctl extension* **  

ucl

ucl3Main

The names above should be used as both the Project and Control names as referred to in Visual Basic, as well as the name of the file that is stored on the hard drive (the one in parentheses next to the Project or Control name in VB).

* = The “l” prefix is an abbreviation of the site, in this case short for “Location”

** = The “uc” prefix is an abbreviation of “User Control”

Building a Basic Screen

 Overview

The following procedure defines the steps involved to build a basic screen using Visual Basic 6.0.  The tpriNtRt administrator program is used to begin a new Visual Basic screen.  All the user has to do is add controls and design the layout of the page.  Below is a screenshot of the Visual Basic design interface and descriptions of the layout:

 Starting a New Screen
  1. Run tpriNtRt administrator program D:\locNtRt\tpriNtRt\Apps\tpriNtRtAdmin\tpriNtRtAdmin.exe

  2. Enter screen name, e.g. ‘l3Main’ with appropriate mill site prefix, in this case ‘l’ for Location

  3. Click ‘Generate New Screen’

  4. A list of steps for creating the demo screen is displayed; those items that are checked have been automatically finished, those that are unchecked must be performed manually

 Adding Labels to the Form

A Label object will always be used for the non-changeable background text on a screen.

  1. On the toolbox to the left, choose the label control.

  2. Position the mouse where the object should be placed on the screen, hold down the left mouse button and drag to the desired size.

  3. Naming the object is optional, but should start with lbl.

  4. Set properties for label such as font, fore color, and back color.

For adding additional objects to the screen such as TelePro controls, refer to Section 6.5 [LINK] of this document

 Saving the Project
  1. Select the Menu option File, Save Project

  2. Select the Menu option File, Save uc[name].ctl

 Testing the Page
  1. Remember to close all instances of Internet Explorer when making your page.  If not, the page will not be updated correctly. 

  2. Select the menu option Run, Start With Full Compile (or Ctrl+F5). This ensures that all code is tested and all variables are defined. 

After you are done testing the screen, you must hit the stop button ◼ in order to edit the code or view the page again.


 Publishing Pages

Pages can be quickly rebuilt and/or published using a program called tpriPublisher.

D:\locNtRt\apps\tpriPublisher\tpriPublisher.exe, this program allows the user to select multiple screens and can rebuild, publish, or both with a single mouse click.

 Helpful Hints
  • Save often:
    Every time you make a change that you wouldn’t want to do again, SAVE your project.  Ctrl+S, click disk button, or File, Save all work.

  • Auto-Complete:
    In the editor, on-the-fly syntax and programming assistance will give you a pull down list for completing what you started typing. You can just press tab to write out what is highlighted.

  • Fine Movements:
    Instead of moving objects on the screen with your mouse (which lacks precision), you can use the ctrl + arrow keys to move the object in fine increments.

  • Lock Controls:
    Once you have finished designing the page, you should lock the controls in place so that they are not accidentally moved (there is no way to undo a move).  This feature can be toggled on and off from the Format menu.  Even if Lock Controls is enabled, you can still move them using the ctrl + arrow keys.

  • Aligning objects:
    To make the objects on your screen align horizontally or vertically, select the objects (either by dragging a selection box with your mouse over them or by individually clicking on each object while holding down the ctrl key) and in the Properties window, set the Top or Left to a number.  This will change the properties for every object you have selected.

  • When editing the code, I move the arrow keys, but nothing happens: 
    Sometimes when you are working in the code view, the focus will still be on an object in the object view.  Every time you press an arrow key or page up/down, the focus is actually changing on the object view.  The fastest way to stop this is to close the object view.

  • Tab Order: 
    It is a good idea to think about the tab order of all of the objects on the screen.  If the user tabs to a non-data input object, it is possible that s/he may not see the focus outline and think the screen has frozen.  Suggestion: allow tabbing only to data entry boxes and command buttons.

  • Toggle between object and code view:
    Ctrl + tab switches the window, but both must be open first in order to toggle between them.

  • Debugging the code: 
    There are many helpful tools used for debugging the code. You may set a breakpoint with the F9 key (the breakpoint stops the code before that line is executed), step through the code with the F8 key, and run the code again with the F5 key.  Once the code is at a break point, you can view variable values by hovering over them with the mouse or entering the Immediate Window and typing “?” followed by your variable and press enter (example:  ?myString).  You may also add a watch on any variable you choose. This is a quick way to view many values at any breakpoint.

  • ‘Conflicting names were found…’ error received when opening a VB project:
    This error is cause when the user-control (*.ctl file) was originally saved in lower case and then later saved using upper case letters. In this case, VB is case-sensitive, but it does not update the code inside the .ctl file. You have to manually change the code in the .ctl file to get rid of the error.   Just open the .ctl file in your favorite text editor and do a search for “Attribute VB_Name =”. This will bring you to the line in the code that needs to be changed.   Just edit the file name that is in quotes to the correct case and you are done.


Adding TelePro’s Standard Controls to a Visual Basic Web Screen

 Adding a Text Box

 Adding an Active Shape

 Adding a Link Button

 Adding Toggle Button

 Adding a Bar Graph

 Adding a Coverage Bar Graph

 Adding a Trend Graph

 Adding a Log Message Display

Error Handling

 General Errors

The following is an overview of the VB error handling logic for ActiveX screen code.  Including the following in your screen code will provide an orderly handling of VB errors if they should occur. 

In the case of an unplanned VB error the program will present a Windows message box reporting the error condition.  Then the program will shut down and close the browser.

Several standard lines of code are required for each screen.  The IobjSafe.bas module is automatically included in your project.  The ErrRpt Subroutine called by the error handler is included in this code.  The following is automatically included at the start of your code.

 

Option Explicit
Event GoToURL(Url As String)
Event ErrorTerminate()
Implements IObjectSafety

The following sample shows the base framework for a Sub or Function

Private Sub DemoSub() As Long)
Dim liTmp AS Integer

 

 On Error GoTo ErrorHandler             <- Set the location to branch to in case of error
 mbError = False                        <- Reset the error flag variable

‘ Start of your Code
‘ blah blah blah         
‘ End of your code

On Error GoTo 0                             

Turn off the error handler for this sub.  This is important.  If you omit this line it is possible that an error generated in some other section of the code will branch here and report the wrong failing program location.

 

Exit Sub                            

Exit   (Note: If you have written a Function then change to Exit Function)

 

ErrorHandler:                             

The following is the general error handler. Based on the error number, the program will proceed.  If your code may generate an error that is expected under normal operating conditions, then handle it here.  If the error is not included in the list of Select statement Case numbers, then the code will call a general purpose reporting procedure.

Select Case Err.Number

Case 9                                   

For example if error number 9 (Subscript out of range) is generated by a bad user data entry, then you may catch it here and respond.

 

MsgBox "The value you entered is not valid!  Please check your input"

                        mbError  = False

 

Case Else

ErrMsg ("DemoSub")      

Update this text to indicate the Sub or Function name.  The string will be included in the error message reporting.

You may also add any additional debug information.

End Select

  

   If mbError Then                                      

If mbError is true then the ActiveX code will call back to the browser via the ErrorTerminate event.       

RaiseEvent ErrorTerminate
 Else
      Resume Next

If you handled the error and would like to have the program continue, then set mbError to False.

End If

End Sub

 VB Runtime Errors

Following are the run-time errors defined by Visual Basic:

 

3

 

 

Return without GoSub

 

 

5

 

 

Invalid procedure call or argument

 

 

6

 

 

Overflow

 

 

7

 

 

Out of memory

 

 

9

 

 

Subscript out of range

 

 

10

 

 

This array is fixed or temporarily locked

 

 

11

 

 

Division by zero

 

 

13

 

 

Type mismatch

 

 

14

 

 

Out of string space

 

 

16

 

 

Expression too complex

 

 

17

 

 

Can't perform requested operation

 

 

18

 

 

User interrupt occurred

 

 

20

 

 

Resume without error

 

 

28

 

 

Out of stack space

 

 

35

 

 

Sub or Function not defined

 

47

 

 

Too many DLL application clients

 

 

48

 

 

Error in loading DLL

 

 

49

 

 

Bad DLL calling convention

 

 

51

 

 

Internal error

 

 

52

 

 

Bad file name or number

 

 

53

 

 

File not found

 

 

54

 

 

Bad file mode

 

 

55

 

 

File already open

 

 

57

 

 

Device I/O error

 

 

58

 

 

File already exists

 

 

59

 

 

Bad record length

 

 

61

 

 

Disk full

 

 

62

 

 

Input past end of file

 

 

63

 

 

Bad record number

 

 

67

 

 

Too many files

 

 

68

 

 

Device unavailable

 

 

70

 

 

Permission denied

 

 

71

 

 

Disk not ready

 

 

74

 

 

Can't rename with different drive

 

 

75

 

 

Path/File access error

 

 

76

 

 

Path not found

 

 

91

 

 

Object variable or With block variable not set

 

 

92

 

 

For loop not initialized

 

 

93

 

 

Invalid pattern string

 

 

94

 

 

Invalid use of Null

 

 

96

 

 

Unable to sink events of object because the object is already firing events to the maximum number of event receivers that it supports

 

 

97

 

 

Can not call friend function on object which is not an instance of defining class

 

 

98

 

 

A property or method call cannot include a reference to a private object, either as an argument or as a return value

 

 

321

 

 

Invalid file format

 

 

322

 

 

Can't create necessary temporary file

 

 

325

 

 

Invalid format in resource file

 

 

380

 

 

Invalid property value

 

 

381

 

 

Invalid property array index

 

 

382

 

 

Set not supported at runtime

 

 

383

 

 

Set not supported (read-only property)

 

 

385

 

 

Need property array index

 

 

387

 

 

Set not permitted

 

 

393

 

 

Get not supported at runtime

 

 

394

 

 

Get not supported (write-only property)

 

 

422

 

 

Property not found

 

 

423

 

 

Property or method not found

 

 

424

 

 

Object required

 

 

429

 

 

ActiveX component can't create object

 

 

430

 

 

Class does not support Automation or does not support expected interface

 

 

432

 

 

File name or class name not found during Automation operation

 

 

438

 

 

Object doesn't support this property or method

 

 

440

 

 

Automation error

 

 

442

 

 

Connection to type library or object library for remote process has been lost. Press OK for dialog to remove reference.

 

 

443

 

 

Automation object does not have a default value

 

 

445

 

 

Object doesn't support this action

 

 

446

 

 

Object doesn't support named arguments

 

 

447

 

 

Object doesn't support current locale setting

 

 

448

 

 

Named argument not found

 

 

449

 

 

Argument not optional

 

 

450

 

 

Wrong number of arguments or invalid property assignment

 

 

451

 

 

Property let procedure not defined and property get procedure did not return an object

 

 

452

 

 

Invalid ordinal

 

 

453

 

 

Specified DLL function not found

 

 

454

 

 

Code resource not found

 

 

455

 

 

Code resource lock error

 

 

457

 

 

This key is already associated with an element of this collection

 

 

458

 

 

Variable uses an Automation type not supported in Visual Basic

 

 

459

 

 

Object or class does not support the set of events

 

 

460

 

 

Invalid clipboard format

 

 

461

 

 

Method or data member not found

 

 

462

 

 

The remote server machine does not exist or is unavailable

 

 

463

 

 

Class not registered on local machine

 

 

481

 

 

Invalid picture

 

 

482

 

 

Printer error

 

 

735

 

 

Can't save file to TEMP

 

 

744

 

 

Search text not found

 

 

746

 

 

Replacements too long

 

Adding Property Pages to the ActiveX Control

 ...

The following sequence is used to add property pages to an ActiveX Control.  This sequence was used to add property pages to the TelePro supplied controls.  It is included here for documentation purposes only.

  1. After loading your ActiveX Control in Microsoft Basic you click on Project —> Add Property Page.

  2. Click on the icon of VB Property Page Wizard and on Open button. New window appears: “Property Page Wizard – select The Property Pages”. Two Property Pages are created automatically: StandardFont and StandardColor.

  3. If you want to add a new one then you should click on the button “Add” and the new page name. Repeat this step as many times as you need. You also can change the order of pages using arrows at the left part of the window.

  4. After all you click on the button “Next>”. In this window you can choose which properties will be in your pages (color and font properties are added to “StandardColor” and “StandardFont” automatically).

  5. When all properties have been assigned to the pages click on “Next>” and finally on “Finish”.

Appendix

 Variable Scope Prefixes

Scope

Prefix

Example

Global

g

gsUserName

Module

m

msUserName

Local to procedure

l

lsUserName

Argument by value (within a function)

av

avsUserID

Argument by reference (within a function)

ar

arsUserID

 Variable Data Types

Use the following prefixes to indicate a variable's data type.

Data type       

Prefix

Example

Boolean

bln

blnFound

Byte

byt

bytRasterData

Collection object

col

colWidgets

Currency        

cur

curRevenue

Date Time      

dt        

dtStart

Date   

d         

dStart

Time   

t          

tStart

Double

dbl      

dblTolerance

Error   

err       

errOrderNum

Integer

i          

iQuantity

Long

Lng

lngDistance

Object

Obj     

objCurrent

Single 

sng     

sngAverage

String  

s

sFName

User-defined type           

udt      

udtEmployee

Variant

v         

vCheckSum

 Prefixes for Controls

Control type

Prefix

Example

3D Panel

pnl

pnlGroup

Animated button

ani

aniMailBox

Check box

chk

chkReadOnly

Combo box, drop

down list box

cbo

cboEnglish

Command button

cmd

cmdExit

Common dialog

dlg

dlgFileOpen

Communications

com

comFax

Control (used within procedures when the specific type is unknown)

ctr

ctrCurrent

Data control

dat

datBiblio

Data-bound combo box

dbcbo

dbcboLanguage

Data-bound grid

dbgrd

dbgrdQueryResult

Data-bound list box

dblst

dblstJobType

Directory list box

dir

dirSource

Drive list box

drv

drvTarget

File list box

fil

filSource

Form

frm

frmEntry

Frame

fra

fraLanguage

Gauge

gau

gauStatus

Graph

gra

graRevenue

Grid

grd

grdPrices

Horizontal scroll bar

hsb

hsbVolume

Image

img

imgIcon

Key status

key

keyCaps

Label

lbl

lblHelpMessage

Line

lin

linVertical

List box

lst

lstPolicyCodes

MAPI message

mpm

mpmSentMessage

MAPI session

mps

mpsSession

MCI

mci

mciVideo

MDI child form

mdi

mdiNote

Menu

mnu

mnuFileOpen

MS Flex grid

msg

msgClients

MS Tab

mst

mstFirst

OLE

ole

oleWorksheet

Outline

out

outOrgChart

Pen BEdit

bed

bedFirstName

Pen HEdit

hed

hedSignature

Pen ink

ink

inkMap

Picture

pic

picVGA

Picture clip

clp

clpToolbar

Report

rpt

rptQtr1Earnings

Shape

shp

shpCircle

Spin

spn

spnPages

Text box

txt

txtLastName

Timer

tmr

tmrAlarm

UpDown

upd

updDirection

Vertical scroll bar

vsb

vsbRate

Slider

sld

sldScale

ImageList

ils

ilsAllIcons

TreeView

tre

treOrganization

Toolbar

tlb

tlbActions

TabStrip

tab

tabOptions

tpriActiveShape

tas

tasMillStatus

tpriBarGraph

tbg

tbgStress

tpriCoverageBar

tcg

tcgRotor

tpriCmdButton

tcb

tcbMainMenu

tpriTextBox

ttb

ttbMill

tpriToggleButton

ttg

ttgRunHold

StatusBar

sta

staDateTime

ListView

lvw

lvwHeadings

ProgressBar

prg

prgLoadFile

RichTextBox

rtf

rtfReport

 Prefixes for Data Access Objects (DAO)

Database object

Prefix

Example

Container

con

conReports

Database

db

dbAccounts

DBEngine

dbe

dbeJet

Document

doc

docSalesReport

Field

fld

fldAddress

Group

grp

grpFinance

Index

idx

idxAge

Parameter

prm

prmJobCode

QueryDef

qry

qrySalesByRegion

Recordset

rec

recForecast

Relation

rel

relEmployeeDept

TableDef

tbd

tbdCustomers

User

usr

usrNew

Workspace

wsp

wspMine

Some Examples:

Dim dbBiblio As Database
Dim recPubsInNY As Recordset, strSQLStmt As String
Const DB_READONLY = 4                                               ' Set constant.
'Open database.
Set dbBiblio = OpenDatabase("BIBLIO.MDB")
' Set text for the SQL statement.
strSQLStmt = "SELECT * FROM Publishers WHERE _
          State = 'NY'"
' Create the new Recordset object.
Set recPubsInNY = db.OpenRecordset(strSQLStmt, _
          dbReadOnly)
 Suggested Prefixes for Menus

Menu caption sequence  

Menu handler name

File Open

mnuFileOpen

File Send Email

mnuFileSendEmail

File Send Fax

mnuFileSendFax

Format Character

mnuFormatCharacter

Help Contents

mnuHelpContents

  • No labels