
01-25-2004, 10:12 PM
|
|
Newcomer
|
|
Join Date: Jan 2004
Posts: 11
|
|
Plz Help. ASAP
|
im not sure whats wrong with my code that makes it like this but in my ouput on this survey program im doing.....the numbers arent where theyre supposed to be. like basketball is blank...the tally number for it is alone at the end........could anyone plz help me fix this.
here is a pic and what i have in code.
Private Type SurveyRecord
strFavSport As String * 15
strFavTeam As String * 15
strFavAthlete As String * 30
strTVSport As String * 15
strSportPlay As String * 3
End Type
Private Sub cmdTally_Click()
'ALL DECLARATIONS********************************************************** ***
'declare constants for sports
Const strBasketball As String * 15 = "Basketball"
Const strFootball As String * 15 = "Football"
Const strHockey As String * 15 = "Hockey"
Const strOther As String * 15 = "Other"
Const strYes As String * 3 = "Yes"
Const strNo As String * 2 = "No"
'declare constants for team names
Const strRaptors As String * 15 = "Raptors"
Const strPackers As String * 15 = "Packers"
Const strLeafs As String * 15 = "Leafs"
Dim udtNewSurvey As SurveyRecord
Dim intSurveyFile As Integer, lngRecLength As Long, lngSurvey As Long
Dim lngNumberofRecord As Long, lngRecordNumber As Long
Dim strAthleteResult As String, strSportResult As String, strTeamResult As String
'what they watch
Dim intBasketball As Integer, intFootball As Integer, intHockey As Integer, intOther As Integer
'if they play sports
Dim intYes As Integer, intNo As Integer
'favourites
Dim intFavBasketball As Integer, intFavFootball As Integer, intFavHockey As Integer, intFavOther As Integer
'store teams
Dim intRaptors As Integer, intPackers As Integer, intLeafs As Integer
'tv teams
Dim intTVBasketball As Integer, intTVFootball, intTVHockey, intTVOther
Dim strTVSport As String
'ALL DECLARATIONS********************************************************** ***
' Open file
intSurveyFile = FreeFile
lngRecLength = LenB(udtNewSurvey)
Open "SportSurveys.dat" For Random As #intSurveyFile Len = lngRecLength
lngNumberofRecord = NumRecords(intSurveyFile, lngRecLength)
lngRecordNumber = 1
Do While lngRecordNumber <= lngNumberofRecord
Get #intSurveyFile, lngRecordNumber, udtNewSurvey
'CALCULATIONS******************************************************
'Adding their favourite sport
If udtNewSurvey.strFavSport = strBasketball Then
intBasketball = intBasketball + 1
ElseIf udtNewSurvey.strFavSport = strFootball Then
intFootball = intFootball + 1
ElseIf udtNewSurvey.strFavSport = strHockey Then
intHockey = intHockey + 1
ElseIf udtNewSurvey.strFavSport = strOther Then
intOther = intOther + 1
End If
'adding their favourite team
If udtNewSurvey.strFavTeam = strRaptors Then
intRaptors = intRaptors + 1
ElseIf udtNewSurvey.strFavTeam = strPackers Then
intPackers = intPackers + 1
ElseIf udtNewSurvey.strFavTeam = strLeafs Then
intLeafs = intLeafs + 1
ElseIf udtNewSurvey.strFavTeam = strOther Then
intOther = intOther + 1
End If
'adding their favourite athlete
strAthleteResult = strAthleteResult & udtNewSurvey.strFavAthlete
'If they play on sport teams
If udtNewSurvey.strSportPlay = strYes Then
intYes = intYes + 1
Else
intNo = intNo + 1
End If
'Adding their favourite tv sport
If udtNewSurvey.strTVSport = strBasketball & Space(2) Then
intTVBasketball = intTVBasketball + 1
ElseIf udtNewSurvey.strTVSport = strFootball Then
intTVFootball = intTVFootball + 1
ElseIf udtNewSurvey.strTVSport = strHockey Then
intTVHockey = intTVHockey + 1
ElseIf udtNewSurvey.strTVSport = strOther Then
intTVOther = intTVOther + 1
End If
lngRecordNumber = lngRecordNumber + 1
Loop
'CALCULATIONS******************************************************
'OUTPUT*************************************************************
'display survey record number
lblRecordNumber.Caption = "Record Number: " & txtSurveyID
'display answer to favourite sports
lblSportResult.Caption = "Favourite Sport: " & _
strBasketball & intBasketball & strFootball & intFootball & strHockey & intHockey & strOther & intOther
'display answer to favourite team
lblTeamResult.Caption = "Favourite Team: " & _
strRaptors & intRaptors & strPackers & intPackers & strLeafs & intLeafs & strOther & intOther
'display answer to favourite athlete
lblAthleteResult.Caption = "Favourite Athlete: " & strAthleteResult
'display answer to sports participation
lblSportPlayResults.Caption = "Sports Participation: " & _
strYes & intYes & strNo & intNo
'display answer to favourite tv sports
lblTVResult.Caption = "Favourite TV Sport: " & _
strBasketball & intBasketball & strFootball & intFootball & strHockey & intHockey & strOther & intOther
'OUTPUT*************************************************************
|
|