|

Visual Basic Code Sample
--
cResume Class --
The following code creates an instance of the 'resume'
object in our
Employment Agency application:
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "cResume"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
'Class Name: CResume
'Author: Rob Leblanc, Vibe Inc.
'Date: 2/15/99
'Description: Contains SQL statments for retreiving Resume information.
Option Explicit
Dim cda As CDataAccess
Dim rs As ADODB.Recordset
Dim Keywords As String
Private mvarResumeID As Integer
Private mvarName As String
Private mvarAddress As String
Private mvarCity As String
Private mvarProvince As String
Private mvarPostalCode As String
Private mvarCountry As String
Private mvarEmail As String
Private mvarPhone As String
Private mvarFax As String
Private mvarSalary As String
Private mvarWages As String
Private mvarFullTime As String
Private mvarPartTime As String
Private mvarContract As String
Private mvarEducation As String
Private mvarQualifications As String
Private mvarFoundRecord As Boolean
Public Function AddRecord() As Boolean
Dim SQLString As String
SQLString = "INSERT
INTO Resumes (Name, Address, City, Province, PostalCode, Country, Email,
Phone, Fax, FullTime, PartTime, Contract, Salary, Wages, Education, Qualifications)"
SQLString = SQLString & "VALUES("
'SQLString = SQLString & "'" & mvarResumeID & "'"
& ","
SQLString = SQLString & "'" & mvarName & "'"
& ","
SQLString = SQLString & "'" & mvarAddress & "'"
& ","
SQLString = SQLString & "'" & mvarCity & "'"
& ","
SQLString = SQLString & "'" & mvarProvince & "'"
& ","
SQLString = SQLString & "'" & mvarPostalCode & "'"
& ","
SQLString = SQLString & "'" & mvarCountry & "'"
& ","
SQLString = SQLString & "'" & mvarEmail & "'"
& ","
SQLString = SQLString & "'" & mvarPhone & "'"
& ","
SQLString = SQLString & "'" & mvarFax & "'"
& ","
SQLString = SQLString & "'" & mvarFullTime & "'"
& ","
SQLString = SQLString & "'" & mvarPartTime & "'"
& ","
SQLString = SQLString & "'" & mvarContract & "'"
& ","
SQLString = SQLString & "'" & mvarSalary & "'"
& ","
SQLString = SQLString & "'" & mvarWages & "'"
& ","
SQLString = SQLString & "'" & mvarEducation & "'"
& ","
SQLString = SQLString & "'" & mvarQualifications &
"')"
cda.cdaGetRecord (SQLString)
End Function
'Moves to the last record in a search result and assigns the
'appropriate values to the mvar variables.
Public Sub SearchMoveLast(Keywords
As String)
Search (Keywords)
rs.MoveLast
FillValues
End Sub
Public Property Let
FoundRecord(ByVal vData As Boolean)
mvarFoundRecord = vData
End Property
Public Property Get FoundRecord() As Boolean
FoundRecord = mvarFoundRecord
End Property
'Passes an SQL statement
to the CDA class which searches for
'the keywords as defined by the user. If the search finds no
'matching records, the user is notified.
Public Function Search(Keywords
As String) As Variant
Dim SQLString As String
SQLString = "SELECT * FROM Resumes WHERE Qualifications LIKE"
& " '%" & Keywords & "%'"
Set rs = cda.cdaGetRecord(SQLString)
If rs.EOF = True Then
mvarFoundRecord = False
Exit Function
Else
mvarFoundRecord = True
Search = rs.GetRows
' Set rs = New ADODB.Recordset
' rs.Open "Resumes", cda.dbConnection, adOpenDynamic, adLockOptimistic
End If
End Function
'Deletes a selected
record from the resume table, either in a
'search or in browse mode.
Public Function Delete(ResID
As Integer) As Boolean
Dim SQLString As String
Dim rs As ADODB.Recordset
SQLString = "DELETE
* FROM Resumes WHERE ResumeID= " & ResID
Set rs = cda.cdaGetRecord(SQLString)
End Function
'Returns one specific
record from the resume table. Used when
'scrolling through a set of records returned in a search.
Public Function GetRecord(SearchNumber
As Integer) As Variant
Dim SQLString As String
Dim rs As Recordset
SQLString = "SELECT
* FROM Resumes WHERE ResumeID =" & SearchNumber
Set rs = cda.cdaGetRecord(SQLString)
GetRecord = rs.GetRows
End Function
'Returns all records
in the resume table when the resume form
'loads. Also returns all records found based on search keywords.
Public Function GetRecords()
As Variant
Dim SQLString As String
SQLString = "SELECT * FROM Resumes"
Set rs = cda.cdaGetRecord(SQLString)
GetRecords = rs.GetRows
'Set rs = New ADODB.Recordset
'rs.Open "Resumes", cda.cn, adOpenDynamic, adLockOptimistic
End Function
'Moves to the last record
in the resume table.
Public Sub MoveLast()
rs.MoveLast
FillValues
End Sub
'Moves to the preceding
record in the resume table when viewing
'the contents of the entire table.
Public Function MovePrevious()
As Boolean
rs.MovePrevious
If rs.BOF = True Then
rs.MoveFirst
MovePrevious = False
Else
FillValues
MovePrevious = True
End If
End Function
'Moves to the first
record in the resume table.
Public Sub MoveFirst()
rs.MoveFirst
End Sub
'Moves to the next record
in the resume table when viewing the
'contents of the entire resume table.
Public Function MoveNext(CurrentRecord
As Integer, IDList As Variant) As Boolean
Dim i As Integer
Dim x As Integer
rs.MoveLast
i = UBound(IDList, 2)
Do Until IDList(0, i) = CurrentRecord
rs.MovePrevious
i = i - 1
Loop
i = i + 1
rs.MoveLast
x = UBound(IDList, 2)
Do Until x = i
rs.MovePrevious
x = x - 1
Loop
'CurrentRecord = IDList(0, i + 1)
'rs.MoveNext
If rs.EOF = True Then
MoveNext = False
Exit Function
Else
FillValues
MoveNext = True
End If
End Function
Public Property Let
Qualifications(ByVal vData As String)
mvarQualifications = vData
End Property
Public Property Get Qualifications() As String
Qualifications = mvarQualifications
End Property
Public Property Let
Education(ByVal vData As String)
mvarEducation = vData
End Property
Public Property Get Education() As String
Education = mvarEducation
End Property
Public Property Let
Contract(ByVal vData As String)
mvarContract = vData
End Property
Public Property Get Contract() As String
Contract = mvarContract
End Property
Public Property Let
PartTime(ByVal vData As String)
mvarPartTime = vData
End Property
Public Property Get PartTime() As String
PartTime = mvarPartTime
End Property
Public Property Let
FullTime(ByVal vData As String)
mvarFullTime = vData
End Property
Public Property Get FullTime() As String
FullTime = mvarFullTime
End Property
Public Property Let
Wages(ByVal vData As String)
mvarWages = vData
End Property
Public Property Get Wages() As String
Wages = mvarWages
End Property
Public Property Let
Salary(ByVal vData As String)
mvarSalary = vData
End Property
Public Property Get Salary() As String
Salary = mvarSalary
End Property
Public Property Let
Fax(ByVal vData As String)
mvarFax = vData
End Property
Public Property Get Fax() As String
Fax = mvarFax
End Property
Public Property Let
Phone(ByVal vData As String)
mvarPhone = vData
End Property
Public Property Get Phone() As String
Phone = mvarPhone
End Property
Public Property Let
Email(ByVal vData As String)
mvarEmail = vData
End Property
Public Property Get Email() As String
Email = mvarEmail
End Property
Public Property Let
Country(ByVal vData As String)
mvarCountry = vData
End Property
Public Property Get Country() As String
Country = mvarCountry
End Property
Public Property Let
PostalCode(ByVal vData As String)
mvarPostalCode = vData
End Property
Public Property Get PostalCode() As String
PostalCode = mvarPostalCode
End Property
Public Property Let
Province(ByVal vData As String)
mvarProvince = vData
End Property
Public Property Get Province() As String
Province = mvarProvince
End Property
Public Property Let
City(ByVal vData As String)
mvarCity = vData
End Property
Public Property Get City() As String
City = mvarCity
End Property
Public Property Let
Address(ByVal vData As String)
mvarAddress = vData
End Property
Public Property Get Address() As String
Address = mvarAddress
End Property
Public Property Let
Name(ByVal vData As String)
mvarName = vData
End Property
Public Property Get Name() As String
Name = mvarName
End Property
Public Property Let
ResumeID(ByVal vData As Integer)
mvarResumeID = vData
End Property
Public Property Get ResumeID() As Integer
ResumeID = mvarResumeID
End Property
Private Sub Class_Initialize()
Set cda = New CDataAccess
End Sub
Private Sub Class_Terminate()
Set cda = Nothing
End Sub
'Assigns the corresponding
values from the recordset to the
'mvar variables to be passed to the resume form.
Public Sub FillValues()
mvarResumeID = rs!ResumeID
mvarName = rs!Name
mvarAddress = rs!Address
mvarCity = rs!City
mvarProvince = rs!Province
mvarPostalCode = rs!PostalCode
mvarCountry = rs!Country
mvarEmail = rs!Email
mvarPhone = rs!Phone
mvarFax = rs!Fax
mvarSalary = rs!Salary
mvarWages = rs!Wages
mvarFullTime = rs!FullTime
mvarPartTime = rs!PartTime
mvarContract = rs!Contract
mvarEducation = rs!Education
mvarQualifications = rs!Qualifications
End Sub

ITI CURRICULUM | FUNDAMENTALS
| VISUAL BASIC | NETWORKING
| JAVA |
ORACLE | WEB SITES | ARTWORK
| CONTACT ME
|