Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 149,934 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,492 people online right now. Registration is fast and FREE... Join Now!




highscore list with sorting help

 
Reply to this topicStart new topic

highscore list with sorting help, helping me start a highscore list that can sort scores from scratch

blueskyz
5 Jun, 2008 - 04:11 AM
Post #1

New D.I.C Head
*

Joined: 17 Apr, 2008
Posts: 2

hey, im currently working on a maths game and i have no idea how to make a highscore list that can sort the scores from highest to lowest. i need help badly as my proejct is soon to be due. i dont really know what you need to see to help me but heres my code anyway. so far this is what ive done..
CODE
Module Module1
    Public playername As String
    Public score As Integer
    Public high As Integer
    Public playername2 As String
    Public score2 As Integer
    Public high2 As Integer
End Module


CODE
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        lblTime.Text = lblTime.Text - 1
        If lblTime.Text = 0 Then
            Timer1.Enabled = False

            Me.Hide()
            If score > high Then
                high = score
                Formplayer.Show()
            Else
                MsgBox("Your Score is lower than Highscore. Please Try Again")
                FormHighScore.Show()
            End If

        End If
    End Sub

CODE
Public Class Formplayer
    Private Sub cmdOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOk.Click
        If TextBox1.Text = "" Then
            MsgBox("enter your name")
        Else
            playername = TextBox1.Text
            Me.Hide()
            FormHighScore.Show()
        End If
    End Sub


CODE
    Private Sub lblTime(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        lbltime2.Text = lbltime2.Text - 1
        If lbltime2.Text = 0 Then
            Timer1.Enabled = False


            Me.Hide()
            If score2 > high2 Then
                high2 = score2
                Formplayer2.Show()
            Else
                MsgBox("Your Score is lower than Highscore. Please Try Again")
                FormHighScore.Show()
            End If
        End If

    End Sub

CODE
Public Class Formplayer2
    Private Sub cmdOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOk.Click
        If TextBox1.Text = "" Then
            MsgBox("enter your name")
        Else
            playername2 = TextBox1.Text
            Me.Hide()
            FormHighScore.Show()
        End If
        TextBox1.Text = ""
    End Sub

CODE
    Private Sub FormHighScore_VisibleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.VisibleChanged
        lblPlayer.Text = playername
        lblscore.Text = high
        lblplayer2.Text = playername2
        lblscore2.Text = high2
    End Sub


if im missing something u need to see ill post it up. thx for ur time
User is offlineProfile CardPM
+Quote Post

rgfirefly24
RE: Highscore List With Sorting Help
5 Jun, 2008 - 04:45 AM
Post #2

D.I.C Regular
Group Icon

Joined: 7 Apr, 2008
Posts: 335



Thanked: 5 times
Dream Kudos: 150
My Contributions


i'm going to attempt VB code to show you a possible solution

CODE


Dim HighScore(10,2) as String

HighScore(0,0) = playername
HighScore(0,1) = high
HighScore(1,0) = playername2
HighScore(1,1) = high2

Dim count as Integer

for count = 0 to (HighScore.Length/2)

if (HighScore(i,1) < HighScore(i+1, 1) then
Dim temp as String
Dim temp2 as String

temp = HighScore(i,1)
temp2 = HighScore(i,0)
HighScore(i,1) = HighScore(i+1,1)
HighScore(i,0) = HighScore(i+1,0)
HighScore(i+1,1) = temp
HighScore(i+1,0) = temp2
end if
next


now you could also use 2 1 dementional arrays

This post has been edited by rgfirefly24: 5 Jun, 2008 - 04:53 AM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 04:02PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month