Text file not displaying when I run my program

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CrazyWebster
    New Member
    • May 2013
    • 1

    Text file not displaying when I run my program

    I'm creating a diving competion program that

    1. keeps score for up to 16 divers.

    2. Each diver has 8 dives.

    3. There are 8 judges scoring each dives w/scores ranging from 0-10 w/one decimal place.

    4. Each dive has a degree of difficulty from 1-4 w/two decimal places.

    5. To get their final scores, throw-out the highest & the lowest and then add the remaining 6 and multiply by the degree of difficulty.

    The problem I'm running into is that the text file with the names of the divers isn't showing up when I run the program so that I can pick a name from the list.

    Code:
    Public Class Form1
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim dt As New DataTable
            dt.Columns.Add(New DataColumn With
                {.ColumnName = "Identifier", .DataType = GetType(Int32), .AutoIncrement = True})
            dt.Columns.Add(New DataColumn With
                {.ColumnName = "Description", .DataType = GetType(String)})
            dt.Columns.Add(New DataColumn With
                {.ColumnName = "Factor", .DataType = GetType(Decimal)})
            dt.Rows.Add(New Object() {Nothing, "Bellyflop", 4D})
            dt.Rows.Add(New Object() {Nothing, "Canonball", 2D})
            dt.Rows.Add(New Object() {Nothing, "Back Flying Somersault", 3D})
            dt.Rows.Add(New Object() {Nothing, "Back Flying 2 1/2 Somersault", 3.56D})
            dt.Rows.Add(New Object() {Nothing, "Reverse Dive", 3.52D})
            dt.Rows.Add(New Object() {Nothing, "Inward Somersault", 3.36D})
            dt.Rows.Add(New Object() {Nothing, "Inward 1 1/2 Somersault", 3.54D})
            dt.Rows.Add(New Object() {Nothing, "Forward Dive 1/2 Twist", 3.51D})
            ListBox1.DisplayMember = "Description"
            ListBox1.ValueMember = "Factor"
            ListBox1.DataSource = dt
            Label1.DataBindings.Add("Text", dt, "Factor")
            ListBox1.Items.LoadFromFile("Names.txt")
        End Sub
    
        Private Sub ListBox1_SelectedIndexChanged(
            ByVal sender As System.Object,
            ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
            Console.WriteLine("Factor {0}", CDec(ListBox1.SelectedValue))
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim ScoreSum =
                (
                    From T In Me.Controls.OfType(Of NumericUpDown)()
                    Select T.Value).Sum / CDec(ListBox1.SelectedValue)
            TextBox1.Text = ScoreSum.ToString("n2")
        End Sub
    End Class
    
    Module Module1
    
        <System.Runtime.CompilerServices.Extension()> _
        Public Sub LoadFromFile(
            ByVal sender As ListBox.ObjectCollection,
            ByVal FileName As String)
            sender.AddRange(IO.File.ReadAllLines(FileName))
        End Sub
    
    End Module
Working...