Click here to Skip to main content
15,889,200 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Advice: stored procedure parameters, lists of sqlparameters or using sqlparametercollections Pin
Dave Kreskowiak15-Apr-10 12:31
mveDave Kreskowiak15-Apr-10 12:31 
JokeRe: Advice: stored procedure parameters, lists of sqlparameters or using sqlparametercollections Pin
Luc Pattyn15-Apr-10 6:57
sitebuilderLuc Pattyn15-Apr-10 6:57 
QuestionHow to make text go away after a few seconds? Pin
Adam Wike14-Apr-10 4:05
Adam Wike14-Apr-10 4:05 
AnswerRe: How to make text go away after a few seconds? PinPopular
Steven J Jowett14-Apr-10 4:10
Steven J Jowett14-Apr-10 4:10 
GeneralRe: How to make text go away after a few seconds? Pin
Adam Wike14-Apr-10 4:11
Adam Wike14-Apr-10 4:11 
GeneralRe: How to make text go away after a few seconds? Pin
Dalek Dave14-Apr-10 8:35
professionalDalek Dave14-Apr-10 8:35 
AnswerRe: How to make text go away after a few seconds? Pin
William Winner14-Apr-10 8:28
William Winner14-Apr-10 8:28 
QuestionSplitting a .txt file and sorting it Pin
offroaderdan14-Apr-10 3:11
offroaderdan14-Apr-10 3:11 
Experts,

Initally what i want to do is to sort 2 lots of data. 1 sort would be the highscore (the highest of the score, ad the second dort would be through the time (lowest).
I dont't really know what the best way to do this, so that was why i thought i would ask you lot. I also will post up the code i am having a bit of trouble with. This may be able to cope with what i am wanting to do.

I am using 1 button called comtest
2 list boxes called listBox1 and ListBox2
2 textboxes called text1 and text2
Imports System.IO

Public Class Form1
    Dim scores = New System.Collections.Generic.List(Of String)
    Dim names = New System.Collections.Generic.List(Of String)
    Dim test1(0 To 10) As String
    Dim test2(0 To 10) As Integer
    Dim userscore As Integer
    Dim username As String
    Dim a As Integer
    Dim b As Integer
    Dim i As Integer
    Dim strFilename As String = ("High Scores.txt")



Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 
        Call highscore()
        names = New System.Collections.Generic.List(Of String)
        scores = New System.Collections.Generic.List(Of Integer)
        Dim srScores As New IO.StreamReader(strFilename)
        While Not srScores.EndOfStream
            Dim strRead As String = srScores.ReadLine
            ListBox1.Items.Add(strRead)
            Dim strSplit() As String = Split(strRead, ",")
            names.Add(strSplit(0))
            scores.Add(strSplit(1))
        End While
        srScores.Close()


    End Sub

Private Sub comtest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles comtest.Click
    username = Text1.Text
    userscore = Val(Text2.Text)
    For i = 1 To 10
        a = scores(i)
        If userscore >= a Then
            test1(i) = username
            test2(i) = userscore
            For b = i + 1 To 10
                test1(b) = names(b - 1)
                test2(b) = scores(b - 1)
            Next
            Call newscore()
            Exit Sub
        End If
        test1(i) = names(i)
        test2(i) = scores(i)
    Next
End Sub
Private Sub highscore()
    For i = 1 To 10
        ListBox1.Items.Add(names(i))      'this always comes up with an error saying argument out of range
            List2.Items.Add(scores(i))
    Next
End Sub
Private Sub newscore()  ' write
    ListBox1.ClearSelected()
    List2.ClearSelected()
    For i = 1 To 10
        ListBox1.Items.Add(test1(i))
        List2.Items.Add(test2(i))
        names(i) = test1(i)
        scores(i) = test2(i)
    Next
    Dim objWriter As New System.IO.StreamWriter(highScoresFile)

    For i = 1 To 10
        objWriter.Write(names(i) & "," & scores(i))

    Next
    objWriter.Close()
End Sub


If anybody can help that would be great

Many thanks

Dan
AnswerRe: Splitting a .txt file and sorting it Pin
tosch14-Apr-10 3:42
tosch14-Apr-10 3:42 
GeneralRe: Splitting a .txt file and sorting it [modified] Pin
offroaderdan14-Apr-10 3:48
offroaderdan14-Apr-10 3:48 
GeneralRe: Splitting a .txt file and sorting it Pin
tosch14-Apr-10 4:15
tosch14-Apr-10 4:15 
GeneralRe: Splitting a .txt file and sorting it [modified] Pin
offroaderdan14-Apr-10 4:38
offroaderdan14-Apr-10 4:38 
GeneralRe: Splitting a .txt file and sorting it Pin
tosch14-Apr-10 4:48
tosch14-Apr-10 4:48 
AnswerRe: Splitting a .txt file and sorting it [modified] Pin
Ian Shlasko14-Apr-10 5:50
Ian Shlasko14-Apr-10 5:50 
GeneralRe: Splitting a .txt file and sorting it Pin
offroaderdan15-Apr-10 0:12
offroaderdan15-Apr-10 0:12 
GeneralRe: Splitting a .txt file and sorting it Pin
Ian Shlasko15-Apr-10 1:37
Ian Shlasko15-Apr-10 1:37 
GeneralRe: Splitting a .txt file and sorting it Pin
offroaderdan15-Apr-10 1:52
offroaderdan15-Apr-10 1:52 
GeneralRe: Splitting a .txt file and sorting it Pin
Ian Shlasko15-Apr-10 1:58
Ian Shlasko15-Apr-10 1:58 
QuestionErrorprovider within a datatable column Pin
popalzai13-Apr-10 20:49
popalzai13-Apr-10 20:49 
AnswerRe: Errorprovider within a datatable column Pin
Simon_Whale14-Apr-10 3:30
Simon_Whale14-Apr-10 3:30 
GeneralRe: Errorprovider within a datatable column Pin
popalzai14-Apr-10 19:49
popalzai14-Apr-10 19:49 
GeneralRe: Errorprovider within a datatable column Pin
Simon_Whale14-Apr-10 21:55
Simon_Whale14-Apr-10 21:55 
QuestionHow to consume WCF service throgh Visual Basic 6.0 application Pin
amit k mistry13-Apr-10 10:28
amit k mistry13-Apr-10 10:28 
AnswerRe: How to consume WCF service throgh Visual Basic 6.0 application Pin
nlarson1113-Apr-10 11:08
nlarson1113-Apr-10 11:08 
GeneralRe: How to consume WCF service throgh Visual Basic 6.0 application Pin
amit k mistry13-Apr-10 11:21
amit k mistry13-Apr-10 11:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.