0

だから私は小さな基本でプログラムを作っています。これが私のコードです:

initialiseprogram()

Sub initialiseprogram
  GraphicsWindow.Show()
  GraphicsWindow.Clear()
  GraphicsWindow.FontBold = "True"
  GraphicsWindow.BrushColor = "Green"
  GraphicsWindow.BackgroundColor = "lightgreen"
  GraphicsWindow.Title = "Favorite Football Teams"
  GraphicsWindow.Width = "700"
  GraphicsWindow.CanResize = "false"
  GraphicsWindow.Height = "430"
  GraphicsWindow.FontSize = "20"
  GraphicsWindow.DrawText(50,55, "Please enter the names of five football teams.")
  GraphicsWindow.DrawText(230, 15, "Favorite Football Teams")
  GraphicsWindow.DrawText(230, 20, "___________________")
  ImageLoc = "H:\My Documents\banner-footballpitch.jpg"
  Image = ImageList.LoadImage(ImageLoc)
  GraphicsWindow.DrawImage(Image, 400, 100)  
  'team1:
  GraphicsWindow.DrawText(50, 105, "Team 1:")
  team1textbox = Controls.AddTextBox(180, 100)
  'team2:
  GraphicsWindow.DrawText(50, 155, "Team 2:")
  team2textbox = Controls.AddTextBox(180, 150)
  'team3:
  GraphicsWindow.DrawText(50, 205, "Team 3:")
  team3textbox = Controls.AddTextBox(180, 200)
  'team4:
  GraphicsWindow.DrawText(50, 255, "Team 4:")
  team4textbox = Controls.AddTextBox(180, 250)
  'team5:
  GraphicsWindow.DrawText(50, 305, "Team 5:")
  team5textbox = Controls.AddTextBox(180, 300)
  submitTeamNames = Controls.AddButton("Submit Teams", 460, 320)
  Controls.ButtonClicked = buttonclickedfunction
EndSub

Sub buttonclickedfunction
    If (Controls.LastClickedButton = submitTeamNames) Then
    'team 1:
    team1name = Controls.GetTextBoxText(team1textbox)
    'team 2:
    team2name = Controls.GetTextBoxText(team2textbox)
    'team 3:
    team3name = Controls.GetTextBoxText(team3textbox)
    'team 4:
    team4name = Controls.GetTextBoxText(team4textbox)
    'team 5:
    team5name = Controls.GetTextBoxText(team5textbox)
    If Text.GetLength(team1name) = 0 Then
      GraphicsWindow.ShowMessage("You must enter a team name for team 1", "Alert")
    ElseIf Text.GetLength(team2name) = 0 Then
      GraphicsWindow.ShowMessage("You must enter a team name for team 2", "Alert")
    ElseIf Text.GetLength(team3name) = 0 Then
      GraphicsWindow.ShowMessage("You must enter a team name for team 3", "Alert")
    ElseIf Text.GetLength(team4name) = 0 Then
      GraphicsWindow.ShowMessage("You must enter a team name for team 4", "Alert")
    ElseIf Text.GetLength(team5name) = 0 Then 
      GraphicsWindow.ShowMessage("You must enter a team name for team 5", "Alert")
    Else
      GraphicsWindow.Clear()
      ImageLoc = "H:\My Documents\banner-footballpitch.jpg"
      Image = ImageList.LoadImage(ImageLoc)
      GraphicsWindow.DrawImage(Image, 400, 100)  
      'Drawing team 1 name on next slide
      GraphicsWindow.DrawBoundText(50,105, 265 team1name + ":")
      'Drawing team 2 name on next slide
      GraphicsWindow.DrawBoundText(50,155, 265 team2name + ":")
      'Drawing team 3 name on next slide
      GraphicsWindow.DrawBoundText(50,205, 265 team3name + ":")
      'Drawing team 4 name on next slide
      GraphicsWindow.DrawBoundText(50,255, 265 team4name + ":")
      'Drawing team 5 name on next slide
      GraphicsWindow.DrawBoundText(50,305, 265 team5name + ":")
      initialisenextslide()

    EndIf
  EndIf  
EndSub

Sub initialisenextslide
  GraphicsWindow.DrawText(230, 15, "Favourite Football Teams")
  GraphicsWindow.DrawText(230, 20, "____________________")
  GraphicsWindow.DrawBoundText(50,45, 640, "Please order your teams in preference, 1 being the favourite and 5 the least favourite")
  'team 1 text box
  team1NewTextBox = Controls.AddTextBox(306, 100)
  Controls.SetSize(team1NewTextBox, 35, 32)
  'team 2 text box
  team2NewTextBox = Controls.AddTextBox(306, 150)
  Controls.SetSize(team2NewTextBox, 35, 32)
  'team 3 text box
  team3NewTextBox = Controls.AddTextBox(306, 200)
  Controls.SetSize(team3NewTextBox, 35, 32)
  'team 4 text box
  team4NewTextBox = Controls.AddTextBox(306, 250)
  Controls.SetSize(team4NewTextBox, 35, 32)
  'team 5 text box
  team5NewTextBox = Controls.AddTextBox(306, 300)
  Controls.SetSize(team5NewTextBox, 35, 32)
  'Adding Submit Button
  ResultsButton = Controls.AddButton("Submit Preferences", 460,320)
  Controls.ButtonClicked = resultsSlideSub
EndSub

Sub resultsSlideSub
  If (Controls.LastClickedButton = ResultsButton) Then
    'team 1:
    t1vote = Controls.GetTextBoxText(team1NewTextBox)
    'team 2:
    t2vote = Controls.GetTextBoxText(team2NewTextBox)
    'team 3:
    t3vote = Controls.GetTextBoxText(team3NewTextBox)
    'team 4:
    t4vote = Controls.GetTextBoxText(team4NewTextBox)
    'team 5:
    t5vote = Controls.GetTextBoxText(team5NewTextBox)
    If Text.GetLength(t1vote) = 0 or Text.GetLength(t1vote) >= 2 Then
      GraphicsWindow.ShowMessage("Team 1: You can only input one number for your preference.", "Alert")
    ElseIf Text.GetLength(t2vote) = 0 or Text.GetLength(t2vote) >= 2 Then
      GraphicsWindow.ShowMessage("Team 2: You can only input one number for your preference.", "Alert")
    ElseIf Text.GetLength(t3vote) = 0 or Text.GetLength(t3vote) >= 2 Then
      GraphicsWindow.ShowMessage("Team 3: You can only input one number for your preference.", "Alert")
    ElseIf Text.GetLength(t4vote) = 0 or Text.GetLength(t4vote) >= 2 Then
      GraphicsWindow.ShowMessage("Team 4: You can only input one number for your preference.", "Alert")
    ElseIf Text.GetLength(t5vote) = 0 or Text.GetLength(t5vote) >= 2 Then 
      GraphicsWindow.ShowMessage("Team 5: You can only input one number for your preference.", "Alert")
    Else
      InitialiseVerification()
    EndIf
  Endif
EndSub

Sub InitialiseVerification
  If (t1vote + t2vote + t3vote + t4vote + t5vote = 15) Then
    If (t1vote = t2vote Or t1vote = t3vote Or t1vote = t4vote Or t1vote = t5vote) Then
      GraphicsWindow.ShowMessage("Please make sure you haven't repeated any numbers for each team.", "Alert")
    ElseIf (t2vote = t1vote Or t2vote = t3vote Or t2vote = t4vote Or t2vote = t5vote) Then
      GraphicsWindow.ShowMessage("Please make sure you haven't repeated any numbers for each team.", "Alert")
    Elseif (t3vote = t1vote Or t3vote = t2vote Or t3vote = t4vote Or t3vote = t5vote) Then
      GraphicsWindow.ShowMessage("Please make sure you haven't repeated any numbers for each team.", "Alert")
    Elseif (t4vote = t1vote Or t4vote = t2vote Or t4vote = t3vote Or t4vote = t5vote) Then
      GraphicsWindow.ShowMessage("Please make sure you haven't repeated any numbers for each team.", "Alert")
    Elseif (t5vote = t1vote Or t5vote = t2vote Or t5vote = t3vote Or t5vote = t4vote) Then
      GraphicsWindow.ShowMessage("Please make sure you haven't repeated any numbers for each team.", "Alert")
    Else 
      InitialiseVerificationStage2()
    EndIf
  Else 
    GraphicsWindow.ShowMessage("Please make sure you haven't entered the same rank twice.", "Alert")
  EndIf
EndSub

Sub InitialiseVerificationStage2
  If (t1vote = 1 Or t1vote = 2 Or t1vote = 3 Or t1vote = 4 Or t1vote = 5) Then
    If (t2vote = 1 Or t2vote = 2 Or t2vote = 3 Or t2vote = 4 Or t2vote = 5) Then
      If (t3vote = 1 Or t3vote = 2 Or t3vote = 3 Or t3vote = 4 Or t3vote = 5) Then
        If (t4vote = 1 Or t4vote = 2 Or t4vote = 3 Or t4vote = 4 Or t4vote = 5) Then
          If (t5vote = 1 Or t5vote = 2 Or t5vote = 3 Or t5vote = 4 Or t5vote = 5) Then
            InitialiseResultsSlide()
          Else
            GraphicsWindow.ShowMessage("Your preferences must only consist of a number between 1 and 5", "Alert")
          EndIf
        EndIf
      EndIf
    EndIf
  EndIf

EndSub


Sub InitialiseResultsSlide
  GraphicsWindow.Clear()
  GraphicsWindow.DrawText(230, 15, "Favourite Football Teams")
  GraphicsWindow.DrawText(230, 20, "____________________")
  ImageLoc = "H:\My Documents\banner-footballpitch.jpg"
  Image = ImageList.LoadImage(ImageLoc)
  GraphicsWindow.DrawImage(Image, 400, 100)  
  GraphicsWindow.DrawBoundText(50,60, 640, "Results Table")
  GraphicsWindow.DrawBoundText(50,175, 640, "Overall: ")
  GraphicsWindow.DrawText(50, 65, "____________________")
  GraphicsWindow.DrawText(50, 180, "____________________")
  'Displaying votes
  If (t1vote > t2vote and t1vote > t3vote and t1vote > t4vote and t1vote > t5vote) then
    preferedTeam = team1name
    preferedTeamVotes = t1vote
  ElseIf (t2vote > t1vote and t2vote > t3vote and t2vote > t4vote and t2vote > t5vote) then
    preferedTeam = team2name
    preferedTeamVotes = t2vote
  ElseIf (t3vote > t1vote and t3vote > t2vote and t3vote > t4vote and t3vote > t5vote) then
    preferedTeam = team3name
    preferedTeamVotes = t3vote
  ElseIf (t4vote > t1vote and t4vote > t2vote and t4vote > t3vote and t4vote > t5vote) then
    preferedTeam = team4name
    preferedTeamVotes = t4vote
  ElseIf (t5vote > t1vote and t5vote > t2vote and t5vote > t3vote and t5vote > t4vote) then
    preferedTeam = team5name
    preferedTeamVotes = t5vote
  EndIf
  GraphicsWindow.DrawBoundText(50,100, 350, "The preffered football team was " + preferedTeam + " which achieved " + preferedTeamVotes + " votes!")
  drawOverallTable()
EndSub

Sub drawOverallTable
  If (t1vote = 1) Then
    GraphicsWindow.DrawBoundText(50,210, 350, "Team 1: " + t1vote + " vote")
  Else 
    GraphicsWindow.DrawBoundText(50,210, 350, "Team 1: " + t1vote + " votes")
  EndIf
  If (t2vote = 1) Then
    GraphicsWindow.DrawBoundText(50,240, 350, "Team 2: " + t1vote + " vote")
  Else 
    GraphicsWindow.DrawBoundText(50,240, 350, "Team 2: " + t1vote + " votes")
  EndIf
  If (t3vote = 1) Then
    GraphicsWindow.DrawBoundText(50,270, 350, "Team 3: " + t1vote + " vote")
  Else 
    GraphicsWindow.DrawBoundText(50,270, 350, "Team 3: " + t1vote + " votes")
  EndIf
  If (t4vote = 1) Then
    GraphicsWindow.DrawBoundText(50,300, 350, "Team 4: " + t1vote + " vote")
  Else 
    GraphicsWindow.DrawBoundText(50,300, 350, "Team 4: " + t1vote + " votes")
  EndIf
  If (t5vote = 1) Then
    GraphicsWindow.DrawBoundText(50,330, 350, "Team 5: " + t1vote + " vote")
  Else 
    GraphicsWindow.DrawBoundText(50,330, 350, "Team 5: " + t1vote + " votes")
  EndIf
  RestartButton = Controls.AddButton("Restart", 520,320)
  controls.ButtonClicked = restartButtonSub
EndSub
Sub restartButtonSub
  If (Controls.LastClickedButton = RestartButton) Then
    initialiseprogram()
  EndIf
EndSub

現時点では動作します。しかし、私の後者の Small Basics の知識のおかげで、2 番目のスライドに、現在の投票を送信し、次回は行かずにページを再度ロードするボタンを作成する方法について頭を悩ませてきました。

わかりにくいかもしれないので、やり直します。

ボタンの作り方が分かりました。しかし、ランキングを送信する 2 番目のスライドには、現在のランクを送信する別のボタン (「SubmitPreferences」ボタンと同様) が必要です。これにより、複数のランキング セットを入力できます。準備ができたら、設定の送信ボタンをクリックすると、最終画面 (結果画面) に移動します。

ありがとうございました。入れる必要があるのは1つだけだと言われましたが、それ以上は助けてくれませんでした.

4

1 に答える 1