Basics of Visual FoxPro Programming

Download as pdf or txt
Download as pdf or txt
You are on page 1of 51

The Basics Of Visual FoxPro

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.


What To Learn in Visual Fox Pro

• Working With Command Window


– Creating a New Table
– Modify the Structure of a Table
– Displaying and Editing Data
• Append Command
• Browse Command
• Replace Command
What To Learn in Visual Fox Pro cont.

• Delete and Recall Command


– Pack Command
– Zap Command
– Recall Command
• Run Command
• Set Default
What To Learn in Visual Fox Pro cont.

Creating Control Objects

Project
Database
Table
Form
Report
Menu
What To Learn in Visual Fox Pro cont.

Building Control Objects and its Properties

Textbox
Command Button
Option Group
Check Box
Combo Box
List Box
Page frame
Image frame
Timer
What To Learn in Visual Fox Pro cont.

Basic Codes of FoxPro

Add
Save
Delete
Search
Next Button
Back Button
Timer
Working with Command Window

The Command window is a Visual


FoxPro system window. When you
choose menu commands, Visual FoxPro
language commands are echoed in
the Command window.
Working with Command Window

Creating New Table


Syntax :
create <table name>

To create a table file from


command window type the
word CREATE followed by the
name of the table file, and
press Enter key.
Working with Command Window

Modify the Structure of a Table


Syntax:
Modify Structure

From the command window we


can modify the structure by
typing the MODIFY
STUCTURE command.
Working with Command Window

Displaying and Editing Data

Working from the command window, we can USE a table and then type
one of the following:

APPEND to display the table in Append mode.

BROWSE to display the table in browse mode.

REPLACE to change the contents in more than one record.
Working with Command Window

Displaying and Editing Data


Syntax:
Append
Append Blank

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.
Working with Command Window

Displaying and Editing Data


Syntax:
Browse

Browse - This is a
powerful editing command
provide us facility to edit
records horizontally with
showing us multiple
records at a time.
Working with Command Window

Displaying and Editing Data


Syntax:
Replace <field> with <expr1>

Replace - This is a
powerful editing
command. This is used to
replace a new
value in a field with or
without a condition.
Working with Command Window

Delete and Recall Command


Syntax:
Replace <field> with <expr1>

Replace - This is a
powerful editing
command. This is used to
replace a new
value in a field with or
without a condition.
Working with Command Window

Delete and Recall Command


Syntax:
Pack

Pack - This command is


used to physically remove
all those records which
was marked for deletion.
Working with Command Window

Delete and Recall Command


Syntax:
Zap

Zap- This command is used


to erases all records of
active database
except its structure.
Working with Command Window

Delete and Recall Command


Syntax:
Recall

Recall- This command is


used to unmark the
specified record which was
marked for deletion.
Working with Command Window

Run command
Syntax:
Run [/n]

We can execute any DOS


command or non Visual
FoxPro program without
quitting from Visual FoxPro.
Working with Command Window

Set Default
Syntax:
Set Default To [cPath]

Visual FoxPro uses its


default drive and directory
for
creating files, unless we
specify the path separately.
Creating Control Object

Project
From the menu click File

Select New

Select Project then New File


Creating Control Object

Project Manager
Creating Control Object

Table
From the menu click File

Select New

Select Table then New File


Creating Control Object

Table
Creating Control Object

Form
From the menu click File

Select New

Select Form then New File


Creating Control Object

Form
Creating Control Object

Report
From the menu click File

Select New

Select Form then New File


Creating Control Object

Report
Creating Control Object

Menu
From the menu click File

Select New

Select Form then New File


Creating Control Object

Menu
Building Control Objects
Command
Check Box
List Box
Group Timer

Command
Textbox Option Combo
Button Box Image
Page Frame
Button

Fig.1.1 Form Controls of VFP


Building Control Object

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.
Building Control Object

Text Box Properties

Alignment: center

PasswordChar: *

BackStyle: 0-Transparent
BorderStyle: 0-None
Building Control Object

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.
Building Control Object

Command Button Properties

Caption: Save

Picture:
Building Control Object

Option Group

You can use a group of option buttons to provide a


selection of predetermined choices.
Building Control Object

Option Group Properties

Value =:0
Caption: Yes/No

BackStyle: 0- Transparent
BorderStyle: 0- None
Building Control Object

Check Box

You can use a check box to switch between


three states, True (.T.), False (.F.), and Null
(.NULL.).
Building Control Object

Check Box
Building Control Object

Combo Box

displays a list of items that you can choose an item from.


Building Control Object

List Box

List boxes provide the user with a scrollable list


that contains a number of options or pieces of
information.
Building Control Object

Page Frame

A page frame is a container object that contains


pages, which can contain controls.
Building Control Object
Image

is a graphical control that displays bitmaps that


can't be changed directly.
Building Control Object
Timer

A typical use for the timer is checking the system


clock to determine if it is time to run a program or
application.
Basic Codes of Fox Pro
ADD

select item2
append blank
thisform.txticode.setfocus
thisform.refresh
Basic Codes of Fox Pro
Save

With thisform
Select item2
Append blank
Replace icode with thisform.txtcode.value
Thisform.refresh
endwith
Basic Codes of Fox Pro
Delete

WITH thisform
select item2
delete
thisform.refresh
ENDwith
Basic Codes of Fox Pro
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
Basic Codes of Fox Pro
Next Button

select item2
if !eof() then
skip+1
thisform.refresh
else
messagebox("end of Records")
goto top
thisform.refresh
endif
Basic Codes of Fox Pro
Back Button

select item2
if !bof() then
skip-1
thisform.refresh
else
messagebox("beggining of Records")
goto top
thisform.refresh
endif
Simple Activity

1. Create new project and name it pos


2. Create form name as activity
3. Create table name as Item
4. Input fields:
1. Icode character 3
2. Scode character 2
3. Descri character 15
4. Price numeric 4 decimal: 2
3. Design the GUI
4. Command buttons:
1. Add
2. Save
3. Search
4. Next
5. Back
5. Place a grid that displays the added item
6. Also place a search box for searching item code

You might also like