-
Help with project
I am making a project for school its relatively simple. Its an application that you can add sport teams and add their winings and losses and ties. I have to use a class as well here is my code but i get a null value when i try to display the information.
Code:
Public Class SportsTeam
Dim activeTeam As Team '
Dim Teams(-1) As Team
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim TeamName As String
Dim TeamCity As String
Dim TeamWin As Integer
Dim TeamLoss As Integer
Dim TeamTie As Integer
Dim newTeam As Team
TeamName = InputBox("Enter Team Name:", "Team Name")
TeamCity = InputBox("Enter Team City:", "Team City")
TeamWin = InputBox("Enter the team's wining score cancel if there are no winings:", "Team Wins")
TeamLoss = InputBox("Enter the team's Losing score Cancel to skip:", "Team Loss")
TeamTie = InputBox("Enter the team's tie score Cancel to skip:", "Team Ties")
newTeam = New Team(TeamWin, TeamLoss, TeamTie, TeamName, TeamCity) ' Sets the information user entered into the array accordingly
newTeam.Official = TeamName + TeamCity
ReDim Preserve Teams(Teams.Length) 'increase array by 1
Teams(Teams.Length - 1) = newTeam
End Sub
Private Sub btnFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFind.Click
Me.lstDisplay.Items.Clear() 'Clear previous items
activeTeam.ShowInformation1(Me.lstDisplay)
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
End
End Sub
Private Sub SportsTeam_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
Sorry about there being no comments im in a hurry
as well here is my class code
Code:
Public Class Team
Public Const MIN_REQUIRED_bALANCE As Decimal = 100
Public Const LOW_BALANCE_FEE As Decimal = 1
Private TeamScores As Integer 'Private statements
Private OfficialName As String
Private Information(-1) As CurrentTeam
Private Team As PersonalInfo
Private Structure CurrentTeam ' private structure for transactions
Dim TeamName As String
Dim TeamCity As String
Dim TeamOfficialName As String
Dim TeamWins As Integer
Dim TeamLoss As Integer
Dim TeamTies As Integer
End Structure
Private Structure PersonalInfo ' private structure for information
Dim TeamName As String
Dim TeamCity As String
Dim TeamOfficialName As String
Dim TeamWins As Integer
Dim TeamLoss As Integer
Dim TeamTies As Integer
End Structure
Public Sub ShowInformation1(ByRef displayBox As ListBox)
Dim currentTransaction As CurrentTeam
displayBox.Items.Add("Official Team Name" & vbTab & "Team Name" & vbTab & "Team City" & vbTab & "Team Scores")
For transNum As Integer = 0 To Information.Length - 1
currentTransaction = Information(transNum)
displayBox.Items.Add(currentTransaction.TeamOfficialName & vbTab & currentTransaction.TeamName & vbTab & currentTransaction.TeamCity & vbTab & vbTab & currentTransaction.Scores)
Next transNum
End Sub
Property Official() As String ' Use for creating and implementing account number
Get
Return Team.TeamOfficialName
End Get
Set(ByVal value As String)
Team.TeamOfficialName = value
End Set
End Property
Public Sub MakeDeposit(ByVal Addscore As Decimal, ByRef errorCode As Boolean)
If Addscore > 0 Then
TeamScores += Addscore
errorCode = False
Else
errorCode = True
End If
End Sub
Protected Sub AddTransaction(ByVal TeamName As String, ByVal TeamCity As Boolean, ByVal currentScore As Decimal)
'use length to size array because the value is one greater than the
'current highest index value
ReDim Preserve Information(Information.Length)
Dim NewTransaction As Integer = Information.Length - 1
Information(NewTransaction).TeamName = TeamName
Information(NewTransaction).TeamCity = TeamCity
Information(NewTransaction).Scores = currentScore
End Sub
Property TeamCity() As String 'Team City
Get
Return Team.TeamCity
End Get
Set(ByVal value As String)
Team.TeamName = value
End Set
End Property
Property TeamName() As String 'Team nmae
Get
Return Team.TeamName
End Get
Set(ByVal value As String)
Team.TeamName = value
End Set
End Property
Property TeamWin() As String 'Last name
Get
Return Team.TeamWins
End Get
Set(ByVal value As String)
Team.TeamWins = value
End Set
End Property
Property TeamLoss() As String 'Last name
Get
Return Team.TeamLoss
End Get
Set(ByVal value As String)
Team.TeamLoss = value
End Set
End Property
Property TeamTie() As String 'Last name
Get
Return Team.TeamTies
End Get
Set(ByVal value As String)
Team.TeamTies = value
End Set
End Property
Sub New(ByVal fName As String, ByVal CName As String, ByVal Teamwinings As Integer, ByVal Teamlosses As Integer, ByVal TeamTie As Integer)
Me.TeamWin = Teamwinings
Me.TeamLoss = Teamlosses
Me.TeamTie = TeamTie
Me.TeamName = fName
Me.TeamCity = CName
Me.AddTransaction("New Account", False, TeamScores)
End Sub
Public Sub ShowInformation(ByRef displayBox As ListBox)
Dim currentTransaction As CurrentTeam
displayBox.Items.Add("Official Team Name" & vbTab & "Team Name" & vbTab & "Team City" & vbTab & "Team Wins" & vbTab & "Team Losses" & vbTab & "Team Ties")
For transNum As Integer = 0 To Information.Length - 1
currentTransaction = Information(transNum)
displayBox.Items.Add(currentTransaction.TeamOfficialName & vbTab & currentTransaction.TeamName & vbTab & vbTab & currentTransaction.TeamCity & vbTab & vbTab & currentTransaction.)
Next transNum
End Sub
End Class