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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

Private Sub cmdAdd_Click()<br />

‘Add a new record<br />

datCities.Recordset.AddNew<br />

‘Data must be entered <strong>and</strong> a new record moved to<br />

End Sub<br />

Private Sub cmdDelete_Click ()<br />

‘Delete the currently displayed record<br />

datCities.Recordset.Delete<br />

‘Move so that user sees deleted record disappear<br />

datCities.Recordset.MoveNext<br />

If datCities.Recordset.EOF Then<br />

datCities.Recordset.MovePrevious<br />

End If<br />

End Sub<br />

Object Property Setting<br />

Private Sub cmdSearch_Click()<br />

Dim strSearchFor As String, foundFlag As Boolean<br />

‘Search for the city specified by the user<br />

strSearchFor = UCase(InputBox(“Name of city to find:”))<br />

If Len(strSearchFor) > 0 Then<br />

datCities.Recordset.MoveFirst<br />

foundFlag = False<br />

frmDBMan Caption Database<br />

Management<br />

cmdAdd Caption Add<br />

cmdDelete Caption Delete<br />

cmdSearch Caption Search<br />

cmdQuit Caption Quit<br />

datCities Caption Large World<br />

Cities<br />

Database MEGACTY1.MDB<br />

Name<br />

Record Cities<br />

Source<br />

lblCity Caption City:<br />

txtCity Text (blank)<br />

Data datCities<br />

Source<br />

DataField City<br />

lblCountry Caption Country:<br />

txtCountry Text (blank)<br />

Data datCities<br />

Source<br />

DataField Country<br />

lblPop1995 Caption 1995 Population:<br />

txtPop1995 Text (blank)<br />

Data datCities<br />

Source<br />

DataField pop1995<br />

lblPop2015 Caption 2015 Population:<br />

txtPop2015 Text (blank)<br />

Data datCities<br />

Source<br />

DataField pop2015

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

Saved successfully!

Ooh no, something went wrong!