Rockwell Automation 2708-DH5B2L_DH5B4L Attended Workstation User Manual

Page 147

Advertising
background image

Appendix K

A-B VBASIC and Visual Basic Tips

K–2

The programmer assumed that this statement would clear the second line of
the display and then print “This is a test”. But, this is not what actually
happens! This is compiled as:

CL2 :

PRINT “This is a test” ;

where CL2 is a local label which is effectively ignored.

The rule should be NEVER have a line which looks like:

< identifier > : < rest of line >

unless you INTEND for <identifier> to be a label.

CONSTant Declarations

“CONST name = value” does not quite follow the same rules as variable
assignments in the same position. The major difference is that the type of
‘name’ is determined by the contents of ‘value’. A DEFINT or DEFSNG #,
or $ after the name to set the type explicitly. The trailing symbol is NOT
required when the constant is referenced.

PRINT “text”; : <statement>

A problem for Pascal and C programmers is coding: PRINT “text”,
<statement> instead of: PRINT “text”; : <statement>

If the statement is a function such as “e = ReadStr%(3,s$)” then the result is
for e to retain its previous value, and for an extra 0 or 1 to follow the printed
text.

Advertising
This manual is related to the following products: