PROPERTIES:
CODEING:
Label1 | |
Text | Each Element Seprate With A Semicolon " , " |
Button1 | |
Text | Minimum |
Button2 | |
Text | Maximum |
Public Class Form1
Private Sub TextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If Asc(e.KeyChar) <> 8 Then //Restrict to enter a char
If Not Asc(e.KeyChar) = 44 And Asc(e.KeyChar) < 48 Or Asc(e.KeyChar) > 57 Then
e.Handled = True
End If
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
MsgBox("Minimum Number :" & search("min"))
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
MsgBox("Maximum Number :" & search("max"))
End Sub
Function search(ByVal op As String) As Integer
Dim c As Char = ","c
Dim arry() As String = TextBox1.Text.Split(c)//Separate a data & assign string array
Dim numArray(arry.Length - 1) As Integer
For Each num In arry
If Not num = "" Then
numArray(i) = Val(num) //Convert string to int, after Assign Value
i += 1
End If
Next
If op = "min" Then
Return numArray.Min
Else
Return numArray.Max
End If
End Function
End Class
DESIGNING:Private Sub TextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If Asc(e.KeyChar) <> 8 Then //Restrict to enter a char
If Not Asc(e.KeyChar) = 44 And Asc(e.KeyChar) < 48 Or Asc(e.KeyChar) > 57 Then
e.Handled = True
End If
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
MsgBox("Minimum Number :" & search("min"))
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
MsgBox("Maximum Number :" & search("max"))
End Sub
Function search(ByVal op As String) As Integer
Dim c As Char = ","c
Dim arry() As String = TextBox1.Text.Split(c)//Separate a data & assign string array
Dim numArray(arry.Length - 1) As Integer
For Each num In arry
If Not num = "" Then
numArray(i) = Val(num) //Convert string to int, after Assign Value
i += 1
End If
Next
If op = "min" Then
Return numArray.Min
Else
Return numArray.Max
End If
End Function
End Class
Comments
Post a Comment