Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Plz Help. ASAP


Reply
 
Thread Tools Display Modes
  #1  
Old 01-25-2004, 10:12 PM
JohnnyBoi17 JohnnyBoi17 is offline
Newcomer
 
Join Date: Jan 2004
Posts: 11
Default 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*************************************************************
Attached Images
File Type: jpg pic.JPG (84.6 KB, 8 views)
Reply With Quote
  #2  
Old 01-26-2004, 06:35 AM
lebb's Avatar
lebb lebb is offline
Disillusioned Code Poet

Retired Moderator
* Guru *
 
Join Date: Apr 2002
Location: Tennessee, USA
Posts: 12,808
Default

I recommend that you have a look at Thinker's tutorial on debugging in Tutor's Corner. It will show you how to trace through your code to find exactly where it is going wrong.
__________________
Laura

Ita erat quando hic adveni.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help on runtime error ASAP voodoo_child Installation / Documentation 5 11-27-2003 01:57 AM
VB/SQL for ASP(Please Help ASAP) amdba33 Database and Reporting 0 10-21-2003 11:06 AM
Problem need help ASAP mattww Installation / Documentation 2 03-18-2003 07:27 PM
Dire Straits!! Help needed ASAP nkanakagiri General 2 10-31-2000 02:16 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->