Hey guys,
This is probably an easy fix but at this point, I don't know it . . . heh.
The problem I'm having is the first time I take a value, it gets inserted in the right section. The second time I insert a value, it inserts it in the correct place AND updates the previous value I inserted with the new value. So apparently when I'm doing:
it's pointing contestant AT highscore1 rather than taking the name, company, and score from contestant and then storing it in highscore1.
Anyone know how I can pass that info by value rather than by reference?
Thanks!
This is probably an easy fix but at this point, I don't know it . . . heh.
VB.NET:
Public Class Form1
Public Contestant As New ContestantClass
Public HighScore1 As New ContestantClass
Public HighScore2 As New ContestantClass
Public HighScore3 As New ContestantClass
Public HighScore4 As New ContestantClass
Public HighScore5 As New ContestantClass
Public Class ContestantClass
Private tempname As String
Private tempcompany As String
Private tempscore As String
Public Property Name() As String
Get
Return tempname
End Get
Set(ByVal Value As String)
tempname = Value
End Set
End Property
Public Property Company() As String
Get
Return tempcompany
End Get
Set(ByVal Value As String)
tempcompany = Value
End Set
End Property
Public Property Score() As Decimal
Get
Return tempscore
End Get
Set(ByVal Value As Decimal)
tempscore = Value
End Set
End Property
End Class
Function InsertScore()
If Contestant.Score > HighScore1.Score Then
HighScore5 = HighScore4
HighScore4 = HighScore3
HighScore3 = HighScore2
HighScore2 = HighScore1
HighScore1 = Contestant
ElseIf Contestant.Score > HighScore2.Score Then
HighScore5 = HighScore4
HighScore4 = HighScore3
HighScore3 = HighScore2
HighScore2 = Contestant
ElseIf Contestant.Score > HighScore3.Score Then
HighScore5 = HighScore4
HighScore4 = HighScore3
HighScore3 = Contestant
ElseIf Contestant.Score > HighScore4.Score Then
HighScore5 = HighScore4
HighScore4 = Contestant
ElseIf Contestant.Score > HighScore5.Score Then
HighScore5 = Contestant
End If
UpdateHighScore()
Return 0
End Function
Function UpdateHighScore()
HighScoreBox.Items.Clear()
HighScoreBox.Items.Add(HighScore1.Name & vbTab & HighScore1.Company & vbTab & HighScore1.Score)
HighScoreBox.Items.Add(HighScore2.Name & vbTab & HighScore2.Company & vbTab & HighScore2.Score)
HighScoreBox.Items.Add(HighScore3.Name & vbTab & HighScore3.Company & vbTab & HighScore3.Score)
HighScoreBox.Items.Add(HighScore4.Name & vbTab & HighScore4.Company & vbTab & HighScore4.Score)
HighScoreBox.Items.Add(HighScore5.Name & vbTab & HighScore5.Company & vbTab & HighScore5.Score)
Return 0
End Function
End Class
The problem I'm having is the first time I take a value, it gets inserted in the right section. The second time I insert a value, it inserts it in the correct place AND updates the previous value I inserted with the new value. So apparently when I'm doing:
VB.NET:
HighScore1 = Contestant
it's pointing contestant AT highscore1 rather than taking the name, company, and score from contestant and then storing it in highscore1.
Anyone know how I can pass that info by value rather than by reference?
Thanks!