PB programming is quick to start (you can write in 2002, I will write it in hand, for many years, put it on it to the novice)

xiaoxiao2021-03-06  53

PB programming popular start

Zhang Jinzhu

The first chapter is generally used

1. The start of the program, the OPEN event of Application.

Exit program routine: HALT is exit function

Int Surequit

Surequit = 2

Surequit = MessageBox ("Exit System", "Please confirm the saved data before exiting", Question!, Okcancel !, 2)

If Surequit = 1 Then Halt

2, variable definition valid range:

◎ Declare-Globe global variable, all procedures are effective

◎ Declare-instance local variable can be valid in an object (eg, a form, app, etc.)

◎ Variables defined in the module can be valid in the current module

Definition: (Incounting case in PB is not sensitive)

Constant string ls_homecity = "boston" constant

INT A integer

CHAR C character

Boolean B Boolean

String a string type

Arch of String a [1000] 1000, 0 ~ 1000

String a [3 to 30] array element is 3 to 30, the initial one is a [3], the last one is a [30]

String a [100, 3TO 30] two-dimensional array, one dimension is 0 ~ 100, 2D 3 to 30

String a [] becomes the array, assigns the value (such as A [30] = 333) automatically assigns memory.

Get up UPPERBOUND, the lower bound LowerBound.

operating:

A = "AAAA" "VVVBB" B C

String (b) Convert B into a string type

Integer ("333333333333") will be converted to "333333333333" string 3333333333333

A = A B * C ^ D / E / F% G

◎ Note: The space is subject to a space before the reduction is used to avoid the BUG of PB7.0.

3, function definition:

The first line is the return type and function name, the second line is the variable type and variable name, Tab key plus.

Return is the return of the function, as if the C language is the same, the RETURN function ends

4, open the window

Open (window name)

OpenWithParm (window name, parameter, parent window

5, open sub-forms in the MDI form

Stamped pattern Open OpenSheet (Subform, Parent Windhead Name, 1, Layered!)

Tile style Open OpenSheet (Subform, Parent Windhead Name, 1, Original!)

If you are written under the form of the parent form, you can use opensheet (child form, this, 1, original!)

The third parameter represents the location of the new form in the parent form menu.

6, the basic properties of the control

Control name. X X coordinate

Control name. Y Y coordinate

Control name. Width wide

Control name. Height High ... (Others can see the properties window in the editor)

7, adjust the form mode

this.windowState = maximized!

Form .WindowState = maximized! Form Maximization (other properties window in the editor) 8, INI file read and write

Examples There is an INI file called "mnr.ini", (path in the program where the program is located) is as follows:

[An action]

Preload = YES

You can read it as follows:

A = ProfileString ("Mnr.ini", "Action", "preload", "aaa")

A is a variable, "AAA" is the default data when the data item is in the data item.

You can write it with the following statement (write value yes):

SetProfileString ("Mnr.ini", "Action", "preload", "yes")

9. Variables to be used throughout the program

You can define a structure first, and then define the structure type variable in Globe Declare, manage it.

10, main grammar unit

Condition judgment

How how IF I

how to do

How to il IF

how to do

END IF

Choose Case variable

Case IS <3

...

Case 4 to 7

...

Case Else

...

End chaoose

Circulation to a greater than 5

DO

A = a 1

LOOP Until A> 5 do while a <= 5

A = a 1

Loop DO

A = a 1

LOOP Until A> 5 DO Until A> 5

A = a 1

Loop

Jump out of the cycle exit, continue the next round of cycling Continue

11, message box

Messagebox (title, information) Other help, check the index MessageBox

12, get the current time now ()

SLE_BEGINTIME.TEXT = String (now (), "YYYY-MM-DD 10:00:00")

If it is 2002-7-14 17:22:21 seconds, the output is 2002-7-14 10:00:00

13, list box application

DDLB_BSC.RESET () Clear List Box

I = 1

Do While i <= UpperBound (WINBSC)

IF WINBSC [I] = "".

DDLB_BSC.ADDITEM (WINBSC [i]) adds content items to list boxes

I = i 1

Loop

Chapter II Application Database

1, the use of the DataWindow control

Create a DataWTwOw object DW_HWTJ first, add a DataWindow control DW_REP in the form, and finally set the DataWindow's DataObject property to dw_hwtj.

a) I write the selected line function, using the DataWindow control Click event

if row = 0 Then Return

If Nowrow <> row and norow> = 0 THEN

This.SelectRow (nowrow, false)

END IF

This.selectrow (Row, True)

Nowrow = row

b) I write the sort function, using the Double-click event for the DataWindow control

IF dwo.type = "column" then

LS_COLUMNNAME = dwo.name

END IF

if Nowstate = 'a' TENTHIS.SETSORT (LS_COLUMNNAME "D")

NowState = 'd'

Else

This.setsort (Ls_ColumnName "A")

NowState = 'a'

END IF

This.sort ()

(Effect, double-click once on a list, sort forward, once again, reverse sorting)

c) Sorting

DW_REP.SETSORT ("BSCMC A, XQH A, XQMC A")

DW_REP.SORT ()

(Press BSCMC first, press XQH, press the XQMC to be sorted forward)

d) Save to XLS files

DW_REP.SAVEAS ('', Excel5!, true)

e) read and write:

Write w_netrep_cell.dw_rep.Object.tchpzzs [i] = a

Read a = w_netrep_cell.dw_rep.object.tchpzzs [i]

2, establish a connection to the database

1) Definition

Transaction Localdb

2) Set

MyTrans.dbms = "as"

MyTrans.Database = "SDA"

MyTrans.logpass = "DEF"

MyTrans.ServerName = "dbo"

MyTrans.logid = "ABC"

MyTrans.dbparm = "" "

MyTrans.lock = ""

MyTrans.Userid = "ABC"

MyTrans.autocommit = true

3) connection

Connect connect use localdb;

Disconnect Using Localdb on DISCONNECT;

4) Query multi-line data from the library: (query statement is cured)

Connect use localdb; // connection

if Localdb.sqlcode <0 THEN

MessageBox ("Connect Local Database Failed ...", Localdb.sqlerrtext)

Return 1

END IF

Declare my_cursor cursor for // Defining a cursor

SELECT BSC from BSC ORDER BY BSC Using Localdb; // Execute Query

I = 1;

Open my_cursor; // Open the cursor

Do while not localdb.sqlcode = 100 // until the end

IF i> Upperbound (WINBSC) THEN EXIT

FETCH MY_CURSOR INTO: WINBSC [i]; // Extract data items

I = i 1

Loop

Close my_cursor; // Close the cursor

Disconnect using localdb; // disconnected

5) Query a row of data from the library: (Query statement is cured) Help In the routine, ":" After adding a string refers to the variable of the string Select Employee.emp_lname, Employee.emp_fname

INTO: EMP_LNAME,: EMP_FNAME

From Employee

WHERE EMPLOYE.EMP_NBR =: EMP_NUM

USING EMP_TRAN;

6) Use in data update, deletion, increase, build table, etc.:

Note: Dynamic SQL Format 1 Statement ... Dynamic SQL Format 4 Statement, which is very clear (see Sample)

Perform a statement directly:

Execute Immediate SqlStatement {Using TransactionObject};

Help is very clear, there are not many talks here.

7) Non-cured query statement: This is very important for improving software flexibility, but it is very simple, only on Help is:

Declare my_cursor Dynamic Cursor for SQLSA

String SQL1, SQL2

SQL1 = "SELECT EMP_ID from Department Where Salary> 90000"

SQL2 = "SELECT EMP_ID From Department & <- this is a branch connection symbol, a space behind a space?

WHERE SALY> 20000 "

IF deptid = 200 THEN

Prepare Sqlsa from: SQL1 Using SQLCA;

Else

Prepare SQLSA from: SQL2 Using SQLCA;

END IF

Open dynamic my_cursor;

summary:

There are not many content, but the main things are here, others should understand in practice, these knowledge is developed, the knowledge and depth are enough to start and standard MIS systems. The SQL statement helps have been sufficient, more talks in detail, will not be described.

2002-7-14

转载请注明原文地址:https://www.9cbs.com/read-88301.html

New Post(0)