visual basic code explanations

6 downloads 0 Views 402KB Size Report
Explanations in this grey box are not necessary in the VBA code which runs the DSS ... If one clicked on the orange button before filled the cells concerning ...
VISUAL BASIC CODE EXPLANATIONS 😊 Explanations in this grey box are not necessary in the VBA code which runs the DSS 😊 'Color Legend: 'Blue: global variable (Public… As Integer…); the beginning and the End of the procedures (Sub – End Sub) 'Green: Comments to explain details in the procedures 'Orange: Tests (If… Then… Else… End If) 'Purple: Tests inside primary Tests (If… Then… Else… End If) 'Dark: functions, instructions and commands 'To display VBA code in MS-Excel: with keyboard ALT + F11, in the Ribbon; Developer; zone 'Code' Visual Basic and select the sheet. Public video_tape As Integer ' As "Public", the value can be used in all procedures (Private Sub – End Sub or Sub – End Sub) Private Sub CommandButton1_Click() 'video_tape beginner-advanced level ' "ThisWorkbook.Path" means the address of the folder in which the video sequences are stored video_tape = 1 'The video_tape 1 is selected, this value 1 will be used in the Sub InfosComplementaires() WindowsMediaPlayer1.URL = ThisWorkbook.Path & "\videotape1.avi" 'The video sequence videotape1.avi is loaded End Sub Private Sub CommandButton2_Click() 'video_tape advanced level-proficient level video_tape = 2 'The video_tape 2 is selected, this value 2 will be used in the Sub InfosComplementaires() WindowsMediaPlayer1.URL = ThisWorkbook.Path & "\videotape2.avi" 'The video sequence videotape2.avi is loaded End Sub Private Sub CommandButton3_Click() 'video_tape proficient level- top-level video_tape = 3 'The video_tape 3 is selected, this value 3 will be used in the Sub InfosComplementaires() WindowsMediaPlayer1.URL = ThisWorkbook.Path & "\videotape3.avi" 'The video sequence videotape3.avi is loaded End Sub Sub InfosComplementaires() 'Access to Pedagogic Situations ie.: Complementary informations ' vbCr (visual basic carriage return) means : goto 1 line below ' " _" a space followed by underscore means VBA code continues on the next line On Error Resume Next If Range("C11") = "Please complete the observations" Then MsgBox prompt:="Please complete the observations" ' If one clicked on the orange button before filled the cells concerning behaviours (E2; E4; E6 and E8) _ a message is displayed in the MsgBox Exit Sub Else If Range("b29") = "Difference betwenn levels > 1" Then MsgBox prompt:="Please Study carrefully the behaviours" _ & vbCr & vbCr & _ "your analyze brings out a difference, between levels, above 1" ' If one clicked on the orange button with a difference between the levels greater than 1 _ a message is displayed in the MsgBox Exit Sub End If End If ' ' If video_tape = 1 Then 'video_tape beginner-advanced level ' High Level Test If Range("E30") > 150 And Range("b29") = "Coherent observation" Then ' Message box displayed to resume the analysis of the video MsgBox prompt:="Your analyze in GRASP IN TE-WAZA is top-level" _ & vbCr & vbCr & _ "Resume the analysis of the video, the selected items " _ & vbCr & _ "do not correspond with the Video Tape " & video_tape ' & video_tape displays the number of the Video Tape selected Else ' Proficient Test

If Range("E30") > 100 And Range("b29") = "Coherent observation" Then ' Message box displayed to resume the analysis of the video MsgBox prompt:="Your analyze in GRASP IN TE-WAZA is proficient level" _ & vbCr & vbCr & _ "Resume the analysis of the video, the selected items " _ & vbCr & _ "do not correspond with the Video Tape " & video_tape ' & video_tape displays the number of the Video Tape selected Else ' Advanced Test If Range("E30") > 50 And Range("b29") = "Coherent observation" Then ' Make Advanced Sheet Visible Sheets("advanced").Visible = True ' GoTo Advanced Sheet in cell A1 Sheets("advanced").Select Range("A1").Select Else ' Beginner Test If Range("E30") = 50 And Range("b29") = "Coherent observation" Then ' Make Beginner Sheet Visible Sheets("beginner").Visible = True ' GoTo Beginner Sheet in cell A1 Sheets("beginner").Select Range("A1").Select End If End If End If End If Else If video_tape = 2 Then 'video_tape advanced level-proficient level ' High Level Test If Range("E30") > 150 And Range("b29") = "Coherent observation" Then ' Message box displayed to resume the analysis of the video MsgBox prompt:="Your analyze in GRASP IN TE-WAZA is top-level" _ & vbCr & vbCr & _ "Resume the analysis of the video, the selected items" _ & vbCr & _ "do not correspond with the Video Tape " & video_tape ' & video_tape displays the number of the Video Tape selected Else ' Proficient Test If Range("E30") > 100 And Range("b29") = "Coherent observation" Then ' Make Proficient Sheet Visible Sheets("proficient").Visible = True ' GoTo Proficient Sheet Sheets("proficient").Select Range("A1").Select Else ' Advanced Test If Range("E30") > 50 And Range("b29") = "Coherent observation" Then ' Make Advanced Sheet Visible Sheets("advanced").Visible = True ' GoTo Advanced Sheet Sheets("advanced").Select Range("A1").Select Else ' Beginner Test If Range("E30") = 50 And Range("b29") = "Coherent observation" Then ' Message box displayed to resume the analysis of the video MsgBox prompt:="Your analyze in GRASP IN TE-WAZA is beginner level" _ & vbCr & vbCr & _ "Resume the analysis of the video, the selected items" _ & vbCr & _ "do not correspond with the Video Tape " & video_tape ' & video_tape displays the number of the Video Tape selected End If End If End If End If Else

If video_tape = 3 Then 'video_tape proficient level- top-level ' High Level Test If Range("E30") > 150 And Range("b29") = "Coherent observation" Then ' Make High Level Sheet Visible Sheets("high-level").Visible = True ' GoTo High Level Sheet Sheets("high-level").Select Range("A1").Select Else ' Proficient Test If Range("E30") > 100 And Range("b29") = "Coherent observation" Then ' Make Proficient Sheet Visible Sheets("proficient").Visible = True ' GoTo Proficient Sheet Sheets("proficient").Select Range("A1").Select Else ' Advanced Test If Range("E30") > 50 And Range("b29") = "Coherent observation" Then ' Message box displayed to resume the analysis of the video MsgBox prompt:="Your analyze in GRASP IN TE-WAZA is advanced level" _ & vbCr & vbCr & _ "Resume the analysis of the video, the selected items" _ & vbCr & _ "do not correspond with the Video Tape " & video_tape ' & video_tape displays the number of the Video Tape selected Else ' Beginner Test If Range("E30") = 50 And Range("b29") = "Coherent observation" Then ' Message box displayed to resume the analysis of the video MsgBox prompt:="Your analyze in GRASP IN TE-WAZA is beginner level" _ & vbCr & vbCr & _ "Resume the analysis of the video, the selected items" _ & vbCr & _ "do not correspond with the Video Tape " & video_tape ' & video_tape displays the number of the Video Tape selected End If End If End If End If End If End If End If End Sub Sub retour_feuil1() ' Go Back Observations Sheet ' ' Hide the complementary information sheet ActiveWindow.SelectedSheets.Visible = False ' GoTo Observations Sheet in cell A1 Sheets("Observations").Select Range("A1").Select End Sub Private Sub CommandButton4_Click() ' Erase Observations in cells E2, E4, E6, E8 and GoTo cell A1 Range("E2").Select Selection.ClearContents Range("E4").Select Selection.ClearContents Range("E6").Select Selection.ClearContents Range("E8").Select Selection.ClearContents Range("A1").Select End Sub