sample TextBox1 text: 2,3,4,5,6,7
(event procedure (button click
PHP كود :
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim splt() As String = Me.TextBox1.Text.Split(",")
Dim arr(splt.Count - 1) As Integer
For i = 0 To splt.Length - 1
arr(i) = Val(splt(i))
Next
Label1.Text = GetArrayMaximumValue(arr)
Label2.Text = GetArrayMinimumValue(arr)
DisplayArrayEvenNumbers(arr)
End Sub
function procedure
Maximum
PHP كود :
Function GetArrayMaximumValue(arr As Integer()) As Integer
Return arr.Max()
End Function
OR
PHP كود :
Function GetArrayMaximumValue(arr As Integer()) As Integer
Dim mx As Integer = Integer.MinValue
For i = 0 To arr.Length - 1
If arr(i) > mx Then
mx = arr(i)
End If
Next
Return mx
End Function
function procedure
Minimum
PHP كود :
Function GetArrayMinimumValue(arr As Integer()) As Integer
Return arr.Min()
End Function
OR
PHP كود :
Function GetArrayMinimumValue(arr As Integer()) As Integer
Dim mn As Integer = Integer.MaxValue
For i = 0 To arr.Length - 1
If arr(i) < mn Then
mn = arr(i)
End If
Next
Return mn
End Function
display even numbers
subroutine procedure
PHP كود :
Sub DisplayArrayEvenNumbers(arr As Integer())
For i = 0 To arr.Length - 1
If arr(i) Mod 2 = 0 Then
Label3.Text = Label3.Text & arr(i) & " "
End If
Next
End Sub