Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27513

Stucky on a programing assignment

$
0
0
I'm suppose to write 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 the final score for each diver, throw-out the highest & the lowest scores and then add all 6 and multiply by the degree of difficulty.

The problem I'm running into is that the names of the divers are not showing up for me to pick when I run the program. Any help is greatly appreciated!

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


Viewing all articles
Browse latest Browse all 27513

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>