此按钮的此代码块中有哪些变量?

时间:2013-12-14 18:33:43

标签: vb.net

有人可以告诉我这段代码中的不同变量,如果有可能知道过程的细节也很棒:

Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
    Dim points As Integer = 0
    If IsNumeric(Label68.Text) Then
        points = CInt(Label68.Text)
    End If

    If points = 0 Then
        TextBox191.Text = "Draw!"
    ElseIf points > 0 Then
        TextBox191.Text = "Team 1!"
    ElseIf points < 0 Then
        TextBox191.Text = "Team 2!"
    End If
    'This is a button that shows the scorer the outcome of the cricket match and it is dependent on the totals of both the batting scores, the validation is shown above
End Sub

1 个答案:

答案 0 :(得分:0)

好的我会在这里解释每一行:

'this starts this block of code, it ask for 2 parameters sender and e each one with
'their respective types for example e as eventargs, handles means that this
'routine is fired when button12 is clicked
Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)    Handles Button12.Click

    'here you are declaring an instance of type integer that will take the value of 0
    Dim points As Integer = 0

    'IsNumeric is a function that will return false/true if text property of label68 is numeric
    If IsNumeric(Label68.Text) Then
        ' if it is numeric you are converting the text property of label68 to integer and storing the value in points
        points = CInt(Label68.Text)
    End If

    'and if you undestood what I explained you should be able to read next lines
    If points = 0 Then
        ' if points=0 then you are saving "Draw" in your textbox191 text property
        TextBox191.Text = "Draw!"
    ElseIf points > 0 Then
        TextBox191.Text = "Team 1!"
    ElseIf points < 0 Then
        TextBox191.Text = "Team 2!"
    End If
    'This is a button that shows the scorer the outcome of the cricket match and it is dependent on the totals of both the batting scores, the validation is shown above
End Sub