1 thought on “VFP form question, ask for answer”

  1. 1.3 Visual FoxPro programming foundation

    --------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------

    VFP is developed from FoxPro, and according to the needs of "visual programming", some new operations have been added. Its sentences, functions, and grammatical rules are basically compatible with Xbase (such as DBase, Foxbase, FoxPro) language, and the function is more powerful.

    1. Data and data type

    1. Data Classification
    The data is the object of computer program processing, and it is also the result of the operation.
    The classification of data: numerical data, character data, logical data, etc.
    The classification of data processing levels: constant, variables, functions and expressions.
    2. The type of data
    The data type is the basic attribute of the data. When operating the data, only the same type of data can be operated. If different types of data are operated, the system is judged as grammar errors.

    (1) Character: It consists of the letter (Chinese characters), numbers, spaces, and other ascii code characters.

    The length of the character data is 0 to 254, and each character accounts for 1 byte.

    (2) Currency: When using the currency value, you can use the currency type to replace the numerical type.

    The range of money-type data is:

    -.5807

    . When the number of decimal digits exceeds 4 bits, the system will perform Four houses and five entry treatment. Each currency data accounts for 8 bytes.

    (3) Date type (Date): It is used to save the date value without time.

    The storage format of the date data is "yyyymmdd". Yyyy is the year, accounts for 4 bits, MM is a month, 2 bits, DDs are day, accounting for 2.

    The date data indicates that there are multiple formats, and the most commonly used format is MM/DD/YYYY.

    The range of date of data data is: December 31, 9999, January 1, 0001.

    (4) Date time type (datetime): used to save the date and time value. The storage format of the date timing data is "", where YYYY is the year, accounts for 4 bits, MM is a month, 2 bits, DDs are the day, HH is the hour in the time, accounts for 2 places, MM is in the time of time The minute, 2 bits, SS is the second in the time, accounting for 2.
    The date of time type data may include only one date or only one time value. When the default date value, the system automatically adds December 31, 1999. When the time value is omitted, the midnight zero is automatically added.

    (5) logic (logical): It is used to store data with only two values. The values ​​of the deposit are only two states: true (.t.) And fake (.f.), Occupying 1 byte.

    (6) Numeric (Numeric): It is used to represent the quantity. The length of numerical data data is 1 to 20, and each data accounts for 8 bytes.
    The range of the value of numerical data data is:

    -0. 19 ~ 0. 20

    Fields:

    (7) Double precision (double): used to replace the value type so that it can provide higher numerical accuracy. The dual -precision type can only be used in the definition of the field in the data table, and it uses a fixed -point floating point number form. Different from numerical types, the position of the decimal point of dual -precision data is determined by the input data value. Each dual -precision data accounts for 8 bytes.

    (8) floating -point type (Float): It can only be used in the definition of fields in the data table, including this type to provide compatibility, floating -point types are equivalent in terms of functional and numerical types.

    (9) General type (general): used to store OLE objects, which can only be used for the definition of fields in the data table. This field contains a reference to OLE objects, and the specific content of the OLE object can be an electronic table, text, pictures of a word processor, which is established by other application software.

    (10) integer (Integer): It is used to store values ​​without decimal parts and can only be used for the definition of fields in the data table. In the data table, the integer field occupies 4 bytes, and the range of the value is:

    -

    The integer is stored in the form of binary. Converted to ASCII character storage.

    (11) Remarks (MEMO); Remarks can only be used for the storage of character data blocks, which can only be used for the definition of fields in the data table. In the data table, the remote field occupies 10 bytes and uses these 10 bytes to quote the actual content of the remarks. The actual remarks are limited by the space available space.
    The actual content of the remote field is a great change, and the remark content cannot be directly in the data table (.dbf) file.
    This Systems put the remarks in a relatively independent file. The extension of the file is. DBT.
    Because there are no remarks variables, the remote field is processed, and it needs to be converted into a character -type variable, and then the character -type function is used for processing.

    . The constant and variables

    During the operation of the program, the data that needs to be processed is stored in the internal memory. The memory unit of the storage of variable data is "variable", and the data in it is called the value of the variable.

    1. The constant

    The constant is a named data item, which remains unchanged during the entire operation. Such as PI value, that is, 3. It is a numerical constant. VFP defines the constant of the following types:

    Numerical type constants, such as: 20, 16, 100, 1
    , font constant, and string included in single quotes or dual quotes, such as : "Abcd"
    The logical constant, only two types: .t. And .f.
    Date type constant and date time constant, such as: {^1999-04-22}, {^1999-04-24 10:00 am}
    2. Variable
    VFP has 3 forms of variables:

    Memory variables -memory units that store a single data
    Adling variables -memory unit group with multiple data
    Field variable -The data items stored in the data table
    each variable has a name, called variable name, VFP uses variables through the corresponding variable name. The naming rules of the variable name are:
    (1) composed of letters, numbers, and subordinate lines. Chinese VFP can use Chinese characters as variable names.
    (2) Start with the letters or lower lines, and Chinese VFP can start with Chinese characters.
    (3) The length is 1 to 128 characters, and each Chinese character accounts for 2 characters.
    (4) The retention of VFP cannot be used.
    The scope of variables includes the process of defining its process and the process range called by the process.

    . The operational symbols and expressions

    The computing is the process of processing the data. The symbols of various computing are called operators. The data involved in the operation is called For the number of operations. The expression is used to indicate a certain value of value. It consists of the operating number, variables, functions, objects and other operations in a reasonable form.
    The expression can be used to perform operations, operating characters or test data, and each expression generates unique value. The type of expression is determined by the type of the operator. There are 5 types of computing and expressions in VFP:

    Tlabing operating operator and arithmetic expression
    -string operators and string expressions
    Date operating symbols and date expression Formula
    The relationship symbols and relationship expression
    logical operators and logic expression
    1. An arithmetic operator and arithmetic expression

    The arcordering expression is also called numerical expression. It consists of arithmetic operator, numerical constant, variables, functions, and parentheses. The operation result is a value. For example: 50*2 (70-6) / 8 operation results are 108.00. The format of arithmetic expressions is:

    u003Cvalue 1> u003CTabouts 1> u003CNumeric 2> [u003CTabouts 2> u003CValue 3>…] r
    (1) Arithmetic operator.
    vfp The arithmetic operator is shown in Table 1.1. Among these 6 arithmetic operators, except for the negative "-" is a single-purpose operator, the others are binocular operators. The meaning of their operations is basically the same as that of mathematics.
    Table 1.1 Arithmetic operator

    The operator name description
    add method in the same mathematics
    -subtraction of the same mathematics
    * Mathematics The multiplication
    / Except the division of the same mathematics
    ^or the multiplication of the same math, such as 43
    % to find the remaining 12 % 5 indicates that 12 is divided by division 12 The remaining number of the remainder obtained by 5 is 2

    The priority of the arithmetic operator is:

    () → ^, ** →*,/ → % → ,-

    (2) Writing rules of expression.
    The arcadence expression is different from the expression writing in mathematics. When writing expressions, pay special attention:

    each symbol accounted for 1 block, all symbols must be written one by one side by side writing On the same horizontal line, you cannot write a square or settlement in the upper right or lower right corner. For example: 23 to write 2^3, XL ten x2 should be written as X1 X2.

    The content that was omitted in mathematical expression must be rewritten. For example: 2x should be written as 2*x.

    The parentheses are small (), and parentheses must be paired. For example: 3 [x 2 (y z)] must be written as 3*(x 2*(y z)).

    The symbols that can be represented in VFP should be changed to VFP. For example: change 2πr to 2*Pi*R.

    2. The string operator and string expression
    A string expression consists of a string constant, string variable variable, string function, and string computing symbols. It can be a simple string constant or a combination of several string constants or string variables. There are two character operators provided by VFP (the same level of computing), as shown in Table 1-2.

    Table 1-2 Character operators

    The operator name description
    connection to connect character data
    n-space shift leveling Connect the space of the previous data tail to the tail of the rear data

    The format of the string expression is

    u003CString 1> Strings operating symbol 1> u003C String 2>
    [u003CString operating symbol 2> u003Cstar 3>…]
    For example:
    n "Computer" "World" after connection is: "Computer World"
    "ABC"-"DEFG" connection results: "ABCDEFG"
    "ABC" "DEFG" For: "ABC DEFG"
    The value of the string expression is a string.
    In the quotes in the string, just include the string with another quotation sign. For example:
    qm = "
    s = s qm allTrim (this.edit1.value) qm ", "

    3. Date -time operator and date time expression

    Date -type expression consisting of arithmetic operator " , -", arithmetic expression, date constant, date variables and functions. Date -type data is a special numerical type of data. They can only add " " and reduce " -" operations between them. There are three cases below:

    The two -date data can be reduced, and the result is a numerical type data (the number of days difference between the two dates). For example:
    ^1999 /12 /19}-{^1999/11/16} The result is value type data: 33

    In the data, the result is still one -day data (the date of calculation). For example: {^1999/11/16} 33 Results are date data: {^1999/12/19}

    The numerical data of the number of days can be reduced from the date data The result is still one -date data (the date calculated forward). For example: {^1999/12/19} -33, the result is date data: {^1999/11/16}

    VFP processing the invalid date into empty date.

    4. Class and object operators
    Class and object transportation symbols are specifically used to achieve object -oriented programming. There are two types:
    . ——Plipping the arithmetic, determine the relationship between objects and classes, as well as the subordinate relationship between attributes, events and methods and objects.
    :: —— Active domain operator is used to call the parent class in the subclass.

    5. Name expression
    In VFP, many commands and functions need to provide a name. The names that can be used in VFP are:

    The table /.dbf file name, table /.dbf alias, table /dbf field name, index file name, file name, memory variables and array names, and array names, and array names, and array names, and array names, and array names, Window names, menu names, form names, object names, attribute names, ...

    In the definition of a name in VFP, the following principles need to be followed:

    The letters or down the line start.

    It can only use letters, numbers, and lower line characters in the name.

    The reservation of VFP cannot be used.

    The length of the name can be 1-128 characters, but the field names and indexes in the free table are up to 10 characters. The file name is according to the rules of the operating system.

    The name is not a variable or field, but it can define an expression to replace the variable or field value of the same name.
    The name expression provides flexibility for the command and function of the VFP. Put the name in the variable or array element, you can use a variable in the command or function to replace the name, as long as the variable or array element is stored in a pair of brackets. Such as:

    store "city" to a
    RePlace (a) with "beijing"

    field names are stored in variable A. When using the replace command, Name expression (a) will replace the variable with field names. This method is called indirect reference.

    . Function

    For users, the function in the programming language is no different from the mathematical function. From the function to get a return value (due to variables). From the perspective of programming, the function is a kind of subroutine, which can complete a specific operation.

    1. The classification of the function

    VFP has two functions, one is a user -defined function, and the other is a system function. The custom function is written by the user as needed, and the system function is an internal function provided by VFP, which can be called at any time. rnVFP提供的系统函数大约有380多个,主要分为:数值函数、字符处理函数、表和数据库函数、日期时间函数、类型转换函数、测试函数、菜单函数、窗口函数、数组函数、 SQL query functions, bit computing functions, object feature functions, file management functions, and system calling functions and other 14 categories.

    2. Common functions

    vfp provides a large number of system functions for programmers, and some of the common functions are listed below.
    (1) Mathematics function

    function format description

    abs (n) Find the absolute value of n
    cos (n) to find the string function of n nexp (n) Find the E index function of n
    int (n) to take N integer, and take a smaller integer with negative numbers
    log (n). N2) Find the biggest ones in N1 and N2
    min (n1, n2) Find the smallest person in N1 and N2
    mod (n1, n2) to find N1 except the remaining number of N2
    pi () Seeking Pay rate
    RAND (n) generate random numbers between 0-1
    Round (n1, n2) according to the decimal digits specified by n2 to find the value of the n1 four houses and five Negative symbol
    sin (n) Find the sine function of n
    sqrt (n) to find the square root of n
    tan (n) to find the positive cut function of n
    n (2) string Function

    function format
    The

    alltrim (c) Remove C's front -guide space and tail follower
    asc (C) Find the leftmost character in C. ASCII code value
    at (C1, C2) Return to the starting position (integer value) of C1 in C2
    left (C, n) from the left side of the string C length N NLEN (C) Find String C length
    Right (C, n) to take the sub -string with length n from the right of the string C
    l0Wer (C) to convert the uppercase letter in the string C to a lowercase letter
    Space (n) Returns the string composed of n empty characters
    substr (c, n [, m]) to extract the sub -string of M characters starting from n in the string C. Take all the characters at the beginning of n
    uppper (C) to convert the lowercase letters in the string expression to the capital letter

    (3) Date function
    n function format description
    date () The current date of the system
    time () system current time
    datetime () system current date and time
    dow (d) The week number of date expression D (1 is week) )
    year (d) The year of the date d
    month (d) get the month value of the date D
    day (d) the number of days in the month D
    hour (d) takes time The hours in D
    minute (d) take the number of minutes in time D
    SEC (d) take the second number of time D

    (4) Type conversion function

    function format
    The

    CHR (ASCII code) Return to the corresponding characters corresponding to ASCII code
    ctod (c) conversion C expression is the corresponding date value
    CTOT (C) conversion C expression is the corresponding date time value
    DTOC (D) conversion date expression D is the string
    str (n, n, m ) Conversion numerical expression n is a digital string
    ttoc (d) conversion date time expression D is the string
    Val (c) return the value of the number string C

    five The attributes, events and methods of objects

    Object (Object) is very common in real life, such as: a person is an object and a PC is an object. If you disassemble a PC, there is "display, chassis, soft disk drive, hard disk, keyboard, mouse or mouse, and mouse, that is, the PC object is composed of multiple" sub -"objects Essence At this time, the PC is also called a container object. In visual programming, the object is the basic element of the application. Common objects include forms, text boxes, list boxes, etc.
    From the perspective of visual programming, the object is an entity with attributes (data) and methods (behavioral methods). After the establishment of an object, its operation is described by the attributes, events and methods related to the object.

    1, the attributes of the object

    attributes refer to a description content of the object, which is used to describe a characteristic Each object is described by several attributes. In visual programming, common attributes include title, name (name), background color, fontsize, visible (visible), etc. The appearance and operation of the object can be effectively controlled by modifying or setting certain attributes.
    The setting or modification of the attribute value can be performed by the attribute window, or the attribute of the object can be changed during the program running through the program. The general format of setting the attribute in the program is:

    Table name. Object name. Attribute name = attribute value

    2. Object events

    The so -called event (EVENT) is pre -defined by VFP, which can be recognized by objects, such as clicking (click) event, double -clicking event, load (load) ) Event, mousemove event, etc., different objects can be recognized are not the same. The event of the object is fixed, and the user cannot establish a new event. To this end, VFP provides rich internal events, which are enough to cope with most of the operation needs in Windows.
    Cure procedures (Event Procure) are a program written to handle specific events. When an event is triggered by a user (such as C1ick) or a system triggered (such as load), the object responds to the event. The program code that responds to a certain event is the event process.

    3. The method of the object

    method (Method) is a process associated with the object, but it is different from the general Visual FoxPro process. The method is closely connected to the object, and it is also different from the call method of the general Visual FoxPro process.
    is similar to the event process. The method of VFP belongs to the internal function of the object, but the method is only used to complete a specific function without responding to a certain event, such as addObject method, drawing rectangular method (BOX) method , Release method, etc. The method is also "encapsulated" in the object, and different objects have different internal methods. VFP provides more than a hundred internal methods for different object calls. Different from the incident process, new methods can be established by users according to needs.

    4. Event and method program call

    The event process is called by the event to the event, and its code can also be called by the program during operation, and the method code of the method can only be called by the program during operation.

    It the format of the event code in the program is:

    The table name. Event name

    Yes

    [[variable name>] =] Form name. Object name. Method name
    n 6. Control and objects
    nvisual foxpro programming The biggest feature is to develop applications with good user interfaces at the fastest speed and efficiency in a visible environment. The essence is to use the graphical component provided by VFP to quickly construct the input and output screen interface of the application. Control (Control) is a collective name for a certain graphic component, such as "label control", "text box control", "list box control", etc. The use of controls to create objects is a specific method for constructing the application interface.

    1. Common controls and internal objects

    The common controls are provided by the base class of VFP, a total of 21, each control is represented by the "Form Contire" button, as shown in Table 1-7 (P17).

    2. Form objects

    Forms (form) are the user interface of the application and the basis for programming. Various graphics, images, data, etc. are displayed through the objects in the form or form, so the form is an container object.
    The early version in FoxPro is called screen (Screen), and it is called a window in Visual Basic.

    (1) The structure of the form.
    VFP forms have the same structural characteristics as the window interface of Windows applications. A typical form is icons, title, miniaturization buttons, maximized buttons, closing buttons, mobile bars, tables, and its surrounding borders. All the features except the table can be deleted part or all from the form.

    (2) Form attribute

    In VFP, the attribute of the form is the structural characteristics of the form. By modifying the attributes of the form, the commonly used form attributes in the form are shown in Table 1-8.

    The attribute name
    It to control whether the form is always located in the central
    backcolor in the VFP window or its parent form. Is the control form? Whether there are borders: system (adjustable), single -line, dual -line
    caption forms
    closable for controlling the closing button in the title bar of the format Whether there is a control button in the title bar
    maxbutton is used to control whether there is a maximum button in the title bar of the form. Whether the form can move
    titalBar is used to control whether the form has a title bar
    It to control whether the form is minimalized, maximized or normal
    . If the form is a mode form, the user is accessing Windows Another object in the screen must be closed before the form

    (3) the event and method of the form.

    . Like attributes, only some form events and methods are often used, and many events and methods are rarely used unless you are writing a very complicated application. You can see the list of all form events and methods in the "process" drop -down list box of the code window, or you can see the list of all form events and methods in the "Method Program" tab of the "Properties" window.

    It the most commonly used events and methods below.
    M commonly used form events:

    load event -when the form is installed in memory;

    init event -when the form is initialized; r

    activate event -when the form is activated.

    The order of the above events is load, init, and activate.

    destroy event -when the form is released;

    unload event -when the form is closed.

    The above incident is stimulated by UNLOAD and Destroy.

    Resize event -when the user or program is used to change the size of the form
    .

    Mrely used form method:

    hide method -hide form;
    nshow method -display form;
    nrelease method method —— Release the form;

    Refresh method -refresh the form.

    3. The reference of the object

    (1) the tolerance level of the object. The objects in
    vfp can be divided into two categories according to the properties of the class they are based on: container class objects and control class objects.
    The container class objects can contain other objects, and allow access to these objects, such as form sets, forms, forms and other control categories can only be included in the container object, not other objects, such as command buttons, replicas, repeat Selection box, etc. Table 1-9 (P20) lists the objects that each container can be included.

    (2) the reference of the object.

    The user interface as the application, the form can contain many objects, and these objects may have a hierarchical relationship that contains each other. To quote an object, it is necessary to know the relationship between it compared to the container level. For example, if you want to process a form of a form in a form of a form, you need to reference form sets, forms and controls.

    1) Absolute reference: The object is referenced by providing the compatriot level of the object.
    If the control in the table is invalid, the following addresses need to be provided:

    formset.form.pageframe.page.grid.column.Control.enabled = .F. R n2) Relative reference: When reference objects in the container level, you can pass the
    The shortcuts indicate the object you want to deal with.
    , for example: .frml.cmdl.caption = "Close"
    The title of the cmdl object named FNNL in this form set was set to "Close".

    thisform.cmdl.cappion = "Close"
    The representation of the title (CAPTION) property of the form of this form is "Turn".
    this. Caption = "Turn"
    For the control that needs to change the title, it means set the title (Caption) property of the object to "Turn off".
    this. Parent. Backcolor = RGB (192, 0g0)
    means setting the background color of the parent object of the object to dark red.
    Table 1-10 lists some attributes and keywords. These attributes and keywords allow more conveniently to reference objects from the object level.

    Table 1-10 The attributes and keywords of the object

    Properties or keyword references
    If focus control
    current activity Form
    The active page in the current activity form
    parent direct container
    this This object
    thisform contains the form of the object

    The description: Only use this,
    thisform and.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top
Scroll to Top