I got about 7 hours left to finish this code so any help is welcome.
I am using Microsoft Visual Basic 2015, and I need it to pull out everyone in an array with the same username, and tally their points up, than insert that information into another array with their First Name and Last Name and Gender and Agegroup. I'm pulling the first arrays info from a csv.
---------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------Module modArray Public Structure Athletes Public UserName As String Public LastName As String Public FirstName As String Public Gender As String Public Points As String Public AgeGroup As String End Structure Public TopAthletes(20) As Athletes Public Sub ReadAthletesArray() 'Find csv file Dim FILE_NAME As String = "C:\Users\Jurid\Desktop\TopAthletes\LoadArray.csv" Dim RecordPosition As Integer = 0 'How to read csv If System.IO.File.Exists(FILE_NAME) = True Then Dim objReader As New System.IO.StreamReader(FILE_NAME) Do While objReader.Peek() <> -1 Call LoadWaitingList(objReader.ReadLine(), RecordPosition) RecordPosition = RecordPosition + 1 Loop objReader.Close() ReDim Preserve TopAthletes(RecordPosition) Else MsgBox("File Does Not Exist") End If End Sub Public AthleteArray() As String Public Sub LoadWaitingList(ByVal Newrecord As String, ByVal IndexPosition As Integer) AthleteArray = Split(Newrecord, ",", 6) With TopAthletes(IndexPosition) .UserName = AthleteArray(0) .Points = AthleteArray(1) .LastName = AthleteArray(2) .FirstName = AthleteArray(3) .Gender = AthleteArray(4) .AgeGroup = AthleteArray(5) End With End Sub Public Function StringValue(ByVal IndexValue As Integer) As String With TopAthletes(IndexValue) StringValue = .UserName & "," & .Points & "," & .LastName & "," & .FirstName & "," & .Gender & "," & .AgeGroup End With End Function Public Sub AthletePoints() Dim UserName As String Dim UserPoints() As Integer For i = 0 To TopAthletes.GetUpperBound(0) - 1 UserName = TopAthletes(i).UserName For o = 0 To TopAthletes.GetUpperBound(0) - 1 If UserName = TopAthletes(o).UserName Then UserPoints(i) = TopAthletes(o).Points + UserPoints(i - 1) End If Next Next End Sub End Module
That's the current code.
Ask if you need anymore



Reply With Quote

