Basics of Visual FoxPro Programming
Basics of Visual FoxPro Programming
Objectives:
To be able to give basic information about FoxPro Environment. To give an overview about basic VFP commands. To give an overview about basic VFP controls. To give an overview about basic VFP codes.
Working With Command Window Creating a New Table Modify the Structure of a Table Displaying and Editing Data Append Command Browse Command Replace Command
Textbox Command Button Option Group Check Box Combo Box List Box Page frame Image frame Timer
The Command window is a Visual FoxPro system window. When you choose menu commands, Visual FoxPro language commands are echoed in the Command window.
APPEND - This command is used to add records to the active database file. APPEND Blank - will add a blank record at the bottom of the screen.
Browse - This is a powerful editing command provide us facility to edit records horizontally with showing us multiple records at a time.
Replace - This is a powerful editing command. This is used to replace a new value in a field with or without a condition.
Replace - This is a powerful editing command. This is used to replace a new value in a field with or without a condition.
Pack - This command is used to physically remove all those records which was marked for deletion.
Run command
Syntax: Run [/n]
We can execute any DOS command or non Visual FoxPro program without quitting from Visual FoxPro.
Set Default
Syntax: Set Default To [cPath]
Visual FoxPro uses its default drive and directory for creating files, unless we specify the path separately.
Project
From the menu click File
Select New
Project Manager
Table
From the menu click File
Select New
Table
Form
From the menu click File
Select New
Form
Report
From the menu click File
Select New
Report
Menu
From the menu click File
Select New
Menu
Command Button Page Textbox Option Combo Box Image Frame Button
Text Box
The text box is the basic control that allows users to add or edit data in a Character, Numeric, or Date field in a table.
Alignment: center
PasswordChar: *
BackStyle: 0-Transparent BorderStyle: 0-None
Command Button
is typically used to start an event that performs an action such as closing a form, moving to a different record, printing a report, and so on.
Caption: Save
Picture:
Option Group
You can use a group of option buttons to provide a selection of predetermined choices.
Value =:0
Caption: Yes/No
Check Box
You can use a check box to switch between three states, True (.T.), False (.F.), and Null (.NULL.).
Check Box
Combo Box
List Box
List boxes provide the user with a scrollable list that contains a number of options or pieces of information.
Page Frame
A page frame is a container object that contains pages, which can contain controls.
Image
Timer
A typical use for the timer is checking the system clock to determine if it is time to run a program or application.
ADD
Save
With thisform Select item2 Append blank Replace icode with thisform.txtcode.value Thisform.refresh endwith
Delete
Search
LOCATE for Icode=ALLTRIM(thisform.textsearch.value) IF FOUND() then MESSAGEBOX("Icode found") thisform.txtIcode.Value=Icode thisform.txtScode.Value=Scode thisform.txtDescri.Value=Descri thisform.txtPrice.Value=Price thisform.search.Value="" ELSE MESSAGEBOX("Icode not Found") ENDIF thisform.Refresh
Next Button
select item2 if !eof() then skip+1 thisform.refresh else messagebox("end of Records") goto top thisform.refresh endif
Back Button
select item2 if !bof() then skip-1 thisform.refresh else messagebox("beggining of Records") goto top thisform.refresh endif
Simple Activity
1. 2. 3. 4. Create new project and name it pos Create form name as activity Create table name as Item Input fields: 1. Icode character 3 2. Scode character 2 3. Descri character 15 4. Price numeric 4 decimal: 2 Design the GUI Command buttons: 1. Add 2. Save 3. Search 4. Next 5. Back Place a grid that displays the added item Also place a search box for searching item code
3. 4.
5. 6.