Hi guys I have a standard scoring algorithm but I need to help on a piece of code to only execute the scoring algorithm at certain times.

I want it to be triggered by dates, but the problem arises if the program is used after 2 (or more) dates have passed, the first date will not be added as the second date is the newest and therefore the one that triggers the scoring algorithm.

Extra information:
- The scoring algorithm gets the scores for that week, which are stored in a text file.

Please could someone help with this problem. Thanks :)

Post some scoreFile.txt content andAlso add a few more details regarding the dates used.
I just woke up and w/out a hangover, it is difficult to make sense about:
.If 2dates passed, use the most recent date of the 2?
.What happens if 3+ dates passed?
.Who adds the dates to be used?;a randomGenerator/you/user?
One more thing, post format of date being used.

If 2 dates passed, the scoring system would only record the most recent (because at the moment it executes ‘If gameweekdate < Now’. The same with 3 or more dates, it would only record the most recent.

Basically what I need is to have all the gameweek dates in a file (again generated and uploaded by me, not the program) so the program can reference them.
For example if 5 gameweeks have passed and the program last run on gameweek 2, the program would know that it hasn’t processed the scores for gameweeks 3-5, look them up in the scoreFile.txt and the process the according scores and add them to the users score.

Example scoreFile.txt after 5 gameweeks


The format of the date is DD/MM/YYYY
The data is added to the text file by myself, and then it get into the program by download from a web client in the program.

First off, the code below is not functional as needed and it will throw an Exception.

Imports System.IO
Public Class Form1
    Public myFolder As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\"
    Private myScoreFile As String = myFolder & "scoreFile.txt", myGameDatesFile As String = myFolder & "gameDatesFile.txt"
    Private arMain(), sDateFormat As String, iMyCurrentGameDay As Integer

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Catch ex As Exception
        End Try
    End Sub

    Private Sub test()
        If File.Exists(myScoreFile) Then
            arMain = File.ReadAllLines(myScoreFile) '// read.File.
            If Not arMain.Length = 0 Then '// if .File has content.
                With arMain(0).ToString '// With line1.
                    If .Contains(",") Then
                        iMyCurrentGameDay = .Split(","c).Length - 1 '// get Total games played, from scoreFile.txt.
                    End If
                End With
                If File.Exists(myGameDatesFile) Then
                    arMain = File.ReadAllLines(myGameDatesFile) '// read.File.
                    sDateFormat = "dd/mm/yyyy"
                    For i As Integer = 0 To arMain.Length - 1
                        With arMain(i)
                            If CDate(Format(.ToString, sDateFormat)) > CDate(Format(Now, sDateFormat)) Then
                                ' MsgBox(.ToString)
                            End If
                        End With
                End If
            End If
        End If
    End Sub
End Class

I tried to wrap my head around your issue for the past hour+ and with other projects in mind, I have to leave it as is, beta.code.
I hope IT.might help to figure out how to get the Total.games played and compare them to the gameDates, or at least give you another suggestion that might eventually lead to a solution.

The scoreFile, I edited to only contain 3games and I even created a separate gameDatesFile. Since I'm a hobbyist programmer and have no use to convert/compare dates on a regular basis, hopefully you might be able to enlighten me as well on how to convert a String to a Date w/a proper format and compare that String to DateTime.Now.

In any case, here are the 2files I used to try and help.


Edited 5 Years Ago by codeorder: n/a

Thanks codeorder, once again, I really apreciate the time you spend helping.

As for the date question, all I do is

Dim raceDate As Date

raceDate = FileReader.ReadLine

Hope that helped you :).

As for the system, I have finished it now, your post gave me some good ideas and the text file is now formatted as {racedate, updated} so the program knows whether its updated that score just by a 1 or 0.

>>As for the date question, all I do is
What about the Format of the Date?
For.example: Format = "mm/[B]dd[/B]/yyyy" and you have a Date.FileLine.Read as 01/02/2003 and your .app might mistake the Format as "[B]dd[/B]/mm/yyyy" ?

Thanks for previous input and glad I could be of help. :)

Edited 5 Years Ago by codeorder: n/a

This question has already been answered. Start a new discussion instead.