19.12.2012 Views

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

342 <strong>Computer</strong> <strong>Programming</strong> <strong>Concepts</strong> <strong>and</strong> <strong>Visual</strong> <strong>Basic</strong><br />

is first run, the user should press the comm<strong>and</strong> button to clear the text boxes. After that, for each new city<br />

to be entered into the database, the user should fill the text boxes <strong>and</strong> then press the comm<strong>and</strong> button.<br />

Private Sub cmdAddNew_Click()<br />

datCities.Recordset.AddNew<br />

End Sub<br />

Private Sub cmdQuit_Click()<br />

End<br />

End Sub<br />

Object Property Setting<br />

frm12_3_3 Caption Add Cities to MEGACTY2<br />

datCountries Caption Countries<br />

DatabaseName MEGACTY2.MDB<br />

RecordSource Countries<br />

Visible 0 – False<br />

datCities Caption Cities<br />

DatabaseName MEGACTY2.MDB<br />

RecordSource Cities<br />

Visible 0 – False<br />

cmdAddNew Caption Add New City<br />

cmdQuit Caption Quit<br />

lblCity Caption City:<br />

txtCity DataSource datCities<br />

DataField city<br />

lblCountry Caption Country:<br />

dbcCountry DataSource datCities<br />

DataField country<br />

BoundColumn country<br />

RowSource datCountries<br />

ListField country<br />

lblPop1995 Caption 1995 Population:<br />

txtPop1995 DataSource datCities<br />

DataField pop1995<br />

lblPop2015 Caption 2015 Population:<br />

txtPop2015 DataSource datCities<br />

DataField pop2015<br />

[Run, click on the Add New City comm<strong>and</strong> button, add the data for a couple of cities, <strong>and</strong> click<br />

on Quit. Then place the cities table of MEGACTY2.MDB in a FlexGrid to confirm that the<br />

cities have indeed been added.]<br />

Some possible cities to add are:<br />

City country pop1995 pop2015<br />

Jakarta Indonesia 11.5 21.2<br />

Osaka Japan 10.6 10.6<br />

Lagos Nigeria 10.3 24.4<br />

■ CREATING A DATABASE WITH VISUAL DATA MANAGER<br />

You invoke <strong>Visual</strong> Data Manager (VisData) from <strong>Visual</strong> <strong>Basic</strong> by pressing Alt/Add-Ins/<strong>Visual</strong><br />

Data Manager. The first two entries of the File menu of VisData are Open Database, used<br />

to view <strong>and</strong> alter an existing database, <strong>and</strong> New, used to create a new database. See<br />

Figure 11-3.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!