-2
テキストファイルから多数の勝利とチーム名を読み込もうとしていますが、降順でどれくらい多くの勝利したかによって構造を並べ替えようとしています。しかし、それは私がoutput.wins
で注文させることはありませんし、なぜ私はなぜ分かりません。私は先生が提供した例に従った。 let output.wins = output
では、.
が=
であると言われています。誰かが私が逃したことを指摘してもらえますか?私はちょうど私がうんざりしているものについて正しい方向に答えを探しているわけではありません。VB宿題割り当てで構造体を並べ替える問題があります
Public Class frmScoccer
Structure Team
Dim name As String
Dim wins As Integer
End Structure
Dim output() As Team 'this is going to be holder for the output data.
Private Sub frmScoccer_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'this is going to be doing everything that needs to be done at load time.
Dim grabNames() As String = IO.File.ReadAllLines("Names.txt") 'this is to pull the names from the text file.
Dim names() As String 'this is going to be the array that holds the names.
'this is going assigned the names to the array
Dim grabWins() As String = IO.File.ReadAllLines("Wins.txt") 'this is going to be used to grab the data on wins before it is assigned to the array.
Dim wins(,) 'this is going to hold wins and loses.
nameAssignment(grabNames, output)
winAssignment(grabWins, wins)
countIf(wins, output) 'this is going to count the number of wins per team.
End Sub
Sub countIf(wins, ByRef output)
'this is going to bring the win counter up for a team if the value is true.
For row As Integer = 0 To (wins.getupperbound(0))
output.name(row) = 0
For column As Integer = 0 To (wins.getupperbound(1))
If wins(row, column) = "true" Then
output.wins += 1
End If
Next
Next
End Sub
Sub nameAssignment(grabNames, ByRef output)
'this is goning to be a way to get the names from the input array to the useable array.
Dim line, data() As String
line = grabNames()
data = line.Split(","c)
For Each i As String In data
output.name(i) = data(i)
Next
End Sub
Sub winAssignment(grabWins(), ByRef wins(,))
Dim line, data() As String
For row As Integer = 0 To (grabWins.GetUpperBound(0))
line = grabWins(row)
data = line.Split(","c)
For column As Integer = 0 To (grabWins.GetUpperBound(1))
wins(row, column) = data(column)
Next
Next
End Sub
Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles btnDisplay.Click
'this is going to display the output
Dim query = From win In output
Let output.wins = output
Order By output Descending
Select win
For Each win In query()
dgvTeamWins.DataSource = query.Tolist
dgvTeamWins.CurrentCell = Nothing
dgvTeamWins.Columns("name").HeaderText = "Team"
dgvTeamWins.Columns("wins").HeaderText = "Wins"
Next
End Sub
End Class
'薄暗いクエリで
を交換することによって修正されましたか? – GSerg
「私は答えを探していません...」しかし、それはまさにSOのことです!その質問と*回答*サイト。実装に応じて動作するかどうかの提案や一般的なアイデア用ではありません。 @Plutonix。 – Plutonix
公正なポイント。 – Grimmjow91