Option Explicit On
Option Strict On
Public Class MainForm
Dim Lottos As New List(Of Lotto)
Private Structure Lotto
Public Datum As String
Public Number() As Integer
End Structure
' csv file Format
' Date , Number 1, Number 2,Number 3, Number 4, Number 5
Private Sub xDisplayButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xDisplayButton.Click
' Prepare file to be parsed
Dim Delimiters() As Char = {CChar(",")}
Dim tfp As Microsoft.VisualBasic.FileIO.TextFieldParser = My.Computer.FileSystem.OpenTextFieldParser("fantasyfive.txt", Delimiters)
' List to contain read in lottos
Dim NewLotto As Lotto
' Define stringBuild to speed up the building of the string.
Dim listText As New System.Text.StringBuilder
Dim Fields() As String
While (tfp.EndOfData = False)
NewLotto = New Lotto
Fields = tfp.ReadFields
' The Fields array now contains the following data
' Fields(0) => The Day
' Fields(1) => The Date
' Fields(2) => Number 1
' Fields(3) => Number 2
' Fields(4) => Number 3
' Fields(5) => Number 4
' Fields(6) => Number 5
NewLotto.Datum = CDate(Fields(1)).ToString("MM dd yyyy") ' The format extension is Case-sensitive.
ReDim (NewLotto.Number(4))<---error says 'Redim statements require a parenthesized list of the new bounds of each dimension of the array'
For i As Integer = 1 To 5
NewLotto.Number(i - 1) = CInt(Fields(i + 1))
Next()
' Sort the number
Array.Sort(NewLotto.Number)
' Add it to the collection of other lottos
Lottos.Add(NewLotto)
listText.AppendLine(Lottos(Lottos.Count - 1).Datum)
' add listbox
Me.ListBox1.Items.Add(Lottos(Lottos.Count - 1).Datum)
End While
Me.xDatesLabel.Text = listText.ToString
tfp.Close()
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
If Me.ListBox1.SelectedIndex <> -1 Then
Me.xLbl_Lotto.Text = _
Lottos(Me.ListBox1.SelectedIndex).Number(0) & " " & _
Lottos(Me.ListBox1.SelectedIndex).Number(1) & " " & _
Lottos(Me.ListBox1.SelectedIndex).Number(2) & " " & _
Lottos(Me.ListBox1.SelectedIndex).Number(3) & " " & _
Lottos(Me.ListBox1.SelectedIndex).Number(4)
End If
End Sub
End Class
Also, here's a screenshot of the form.
Attached File(s)
-
Doc2.doc (88K)
Number of downloads: 35

New Topic/Question
Reply





MultiQuote





|