You are on page 1of 14

Visual Foxpro Tutorial 1 By: David Hosick

Introduction
For this project we will make a small application that prints Button pushed when you hit a button. The other button will clear the screen. Primary Aim: How to create a new project How to create a new !orm Demonstrates how to desi"n a !orm Secondary Aim How to pro"ram object events

#ection $% &reatin" the '() *'raphical (ser )nter!ace+


#tep $. Be"in by openin" Fo,-ro. .nce the pro"ram loads select File -> New. To the ri"ht is a screen capture o! the screen. /nsure 0-roject1 is selected and then click on 02ew !ile1. 2ote that you will be !orced to save your !ile ri"ht away.

#tep 3. )! you1ve created a new Fo,-ro project success!ully you should see the 0-roject 4ana"er1. This screen is used to connect all the separate pieces to"ether in order to make a !ull !led"ed pro"ram. )mmediately we will click on 0Documents1.

#tep 5. 6ithin the 0Documents1 tab% make sure 0Forms1 is hi"hli"hted% and then click on 02ew1

#tep 7. 6e will be makin" a !orm !rom scratch8 so click on 02ew Form1.

#tep 9. :our screen should now look similar to the one below.

#tep ;. )! you1re lucky you will see the 0Form &ontrols Toolbars1 in your display. )! not% you will have to activate it. )! you cannot see the Form &ontrols Toolbar% click on View -> Form Controls Tool ar

#tep <. 2ow% we will create a new /ditbo,. /ditbo,es are used to display te,t to the user. To make a new editbo,% select the /ditbo, picture !rom the Form &ontrols Toolbar.

#tep =. 4ove your cursor to the blank !orm and draw a bo,. (pon releasin" the mouse button an editbo, will be created. For our purposes% make sure not to cover up all the !orm with the editbo,% leave space !or some buttons.

#tep >. 6e now want to create two buttons !or users to push. 'o over to the 0Form &ontrols Toolbar1 and click on the button icon.

#tep $?. 2e,t% draw two separate buttons on the !orm. (pon completion your !orm should be similar to the one pictured below.

-art 3. -ro"rammin" .bject /vents


#tep $$. 6e will now re@uire the 0-roperties Toolbar1. However% you probably closed it earlier. &lick on the button identi!ied below to open and close the 0-roperties Toolbar1. 4ove to the ne,t step with the toolbar open.

#tep $3. &lick on the 0&ommand$1 button you made in your new !orm. (pon clickin" it a sin"le time you will see the properties window displays this button1s properties. *This is hi"hli"hted by the blue circle in the dia"ram below+

#tep $5. 6e will now switch to the button1s 4ethods. 6e do this by clickin" on the 04ethod1 tab in the properties toolbar.

#tep $7. 2ow% double click on the 0&lick1 method. This will open a window that contains all the pro"rammin" that is run whenever the 0&ommand$1 button is clicked.

#tep $9. 2ow that the click methods window is open% type in the !ollowin" code.
Form1.Edit1.Value = Form1.Edit1.Value + Button pushed + CHR(13) Form1.Edit1.Re resh

.nce complete% the window should appear as !ollows. :ou can then close this window.

#tep $;. )1m "oin" to speed thin"s up a bit now and skip a !ew steps. ) want you to open the 0&lick1 method !or the 0&ommand31 button. Do this by selectin" the &ommand3 button !rom the new !orm you made. Then move your mouse to the properties toolbar on the ri"ht hand side o! the screen. #elect the 0method1 tab and then double click on the 0&lick1 method. )! you are success!ul you will see the !ollowin" window open. 2ote the items circled in blue.

#tep $<. 6e will now make the &ommand3 button clear all the te,t stored in the /ditbo,. Type in the !ollowin" code.
Form1.Edit1.Value=!! Form1.Edit1.Re resh

.nce complete% your method should look as !ollows. :ou may now close this window.

#tep $=. 6e are now !inished creatin" our toy% and are ready to test it. Do this by clickin" on your new !orm *so it is hi"hli"hted and active+. :ou can then move your mouse to the toolbar at the very top o! the screen and select F!"# -> "$N F!"#

#tep $>. :ou should now see somethin" similar to below. -ushin" one o! the buttons will print Button -ushed while the other button will clear the editbo,.

#tep 3?. Tutorial &omplete.

You might also like