0

I am creating a score tournament system. I have created an entry screen where a user can enter multiple scores for a group. When the submit button is pressed, I need the scores to scores to be logged so that they can go into lists on my leader board page.

Below is my current code. Is it possible to refresh the form every time the user selects submit, but also have the results from the form before it was refreshed be logged? If not, I'm worried I would need to create a new form for each group. Surely this isn't the case?

Public Class GT_Entry
    Dim Activityscore1 As Integer
    Dim Activityscore2 As Integer
    Dim Activityscore3 As Integer
    Dim Activityscore4 As Integer
    Dim Activityscore5 As Integer
    Dim Groupname As String
    Private Sub Submit_Click(sender As System.Object, e As System.EventArgs) Handles Submit.Click
        Activityscore1 = R1S.Text
        Activityscore2 = R2S.Text
        Activityscore3 = R3S.Text
        Activityscore4 = R4S.Text
        Activityscore5 = R5S.Text
        Groupname = GN.Text
        GN.Clear()
        R1S.Clear()
        R2S.Clear()
        R3S.Clear()
        R4S.Clear()
        R5S.Clear()
    End Sub
the_lotus
  • 12,668
  • 3
  • 36
  • 53
Emily
  • 29
  • 6
  • Wel... you can do what ever you want in .net, it all depends on your data structure. If you separate the UI from the business logic, there should be no problem using the same form for different dataset. – the_lotus Apr 17 '19 at 15:33
  • Sorry, apologies, what is UI and what is business logic? – Emily Apr 17 '19 at 15:34
  • https://softwareengineering.stackexchange.com/a/275559/106469 – djv Apr 17 '19 at 15:50
  • Please turn on Option Strict. This is a 2 part process. First for the current project - In Solution Explorer double click My Project. Choose Compile on the left. In the Option Strict drop-down select ON. Second for future projects - Go to the Tools Menu -> Options -> Projects and Solutions -> VB Defaults. In the Option Strict drop-down select ON. This will save you from bugs at runtime. – Mary Apr 17 '19 at 16:12
  • @Mary just put `Option Strict On` at the top of the current code file. There are times when you *don't* want it on such as emulating c# `dynamic` https://stackoverflow.com/a/2890023/832052 – djv Apr 17 '19 at 16:14
  • @djv Yes, when late binding but I think it will be a while before this OP will be faced with emulating C# dynamic. In 99% of cases Option Strict should be ON. – Mary Apr 17 '19 at 16:19
  • 1
    I don't know what your are doing exactly, but you can have more than one `GT_Entry` variable. You can also have a `List(Of GT_Entry)` and add it any number of `GT_Entry` objects. Btw., UI is **U**ser **I**nterface (i.e. your Forms and Controls) and `business logic` is the logic related to your game but not related to UI or databases. – Olivier Jacot-Descombes Apr 17 '19 at 16:26

1 Answers1

2

There are several ways to approach your problem. I made a class to store the data. Then created a list of that class. Each time the user clicks Submit the data is added to the list. You can iterate the list and access the properties.

Private ScoreList As New List(Of GroupActivityScore)

Private Sub Submit_Click(sender As System.Object, e As System.EventArgs) Handles Submit.Click
    Dim GAS As New GroupActivityScore
    GAS.Score1 = CInt(R1S.Text)
    GAS.Score2 = CInt(R2S.Text)
    GAS.Score3 = CInt(R3S.Text)
    GAS.Score4 = CInt(R4S.Text)
    GAS.Score5 = CInt(R5S.Text)
    GAS.GroupName = GN.Text
    ScoreList.Add(GAS)
    GN.Clear()
    R1S.Clear()
    R2S.Clear()
    R3S.Clear()
    R4S.Clear()
    R5S.Clear()
End Sub

Public Class GroupActivityScore
    Public Property Score1 As Integer
    Public Property Score2 As Integer
    Public Property Score3 As Integer
    Public Property Score4 As Integer
    Public Property Score5 As Integer
    Public Property GroupName As String
End Class
Mary
  • 14,926
  • 3
  • 18
  • 27