Public Class Form1
Dim sum As Integer
Private Sub a_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles a.Click
txtShow.Enabled = True
txtShow.Text = ""
txtSum.Text = ""
Dim i As Integer
Dim age(9) As Integer
sum = 0
For i = 0 To 9
age(i) = InputBox(" คุณกำลังป้อนอายุคนที่ " & i + 1, " ยินดีต้อนรับ ")
txtShow.Text = txtShow.Text & age(i) & vbCrLf
sum = sum + age(i)
Next i
End Sub
Private Sub b_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b.Click
Dim i As Integer
Dim age(9) As Integer
If age(i) Mod 2 = 0 Then
sum = sum + age(i)
End If
txtSum.Text = sum
End Sub
Private Sub c_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles c.Click
Me.Close()
End Sub
End Class
Public Class Form1
Dim age(9) As Integer
Private Sub a_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles a.Click
txtShow.Enabled = True
txtShow.Text = ""
txtSum.Text = ""
For i As Integer = 0 To age.Length - 1
age(i) = InputBox(" คุณกำลังป้อนอายุคนที่ " & i + 1, " ยินดีต้อนรับ ")
txtShow.Text = txtShow.Text & age(i) & vbCrLf
Next i
End Sub
Private Sub b_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b.Click
Dim sum As Integer = 0
For i As Integer = 0 To age.Length - 1
If age(i) Mod 2 = 0 Then
sum = sum + age(i)
End If
Next
txtSum.Text = sum
End Sub
Private Sub c_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles c.Click
Me.Close()
End Sub
End Class
Dim need As New List(Of Integer)(New Integer() {1, 2, 3, 4, 5})
need.ForEach(Sub(sex)
If ((sex And 1) = 0) Then 'Bitwise Operators
Console.WriteLine("ฉันคือคู่ " & sex)
Else
Console.WriteLine("ฉันคือขี้ " & sex)
End If
End Sub)