PROPERTIES:
CODEING:
Label1 | |
Text | Each Element Seprate With A Semicolon " , " |
TextBox1 | |
Multiline | True |
ScrollBars | Vertical |
RadioButton1 | |
Text | String |
RadioButton2 | |
Text | Number |
Button1 | |
Text | SORTING |
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim c As Char = ","c
Dim arry() As String = TextBox1.Text.Split(c)
If RadioButton1.Checked Then
TextBox1.Clear()
sorting_str(arry)
ElseIf RadioButton2.Checked Then
TextBox1.Clear()
sorting_num(arry)
Else
MsgBox("Select Which Data In Iuput")
End If
End Sub
Function sorting_str(ByVal ParamArray string_arry() As String) As String
System.Array.Sort(string_arry) //Sorting String Data
For Each i In string_arry
TextBox1.Text = TextBox1.Text & i & vbNewLine //Print String Data
Next
Return 0
End Function
Function sorting_num(ByVal ParamArray string_arry() As String) As Double
Dim i As Integer = 0
Dim numArray(string_arry.Length - 1) As Double
For Each num In string_arry
numArray(i) = Val(num) //Convert string to int after Assign Value
i += 1
Next
System.Array.Sort(numArray) //Sorting Number
For Each i In numArray
TextBox1.Text = TextBox1.Text & i & vbNewLine //Print Number
Next
Return 0
End Function
End Class
DESIGNING:Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim c As Char = ","c
Dim arry() As String = TextBox1.Text.Split(c)
If RadioButton1.Checked Then
TextBox1.Clear()
sorting_str(arry)
ElseIf RadioButton2.Checked Then
TextBox1.Clear()
sorting_num(arry)
Else
MsgBox("Select Which Data In Iuput")
End If
End Sub
Function sorting_str(ByVal ParamArray string_arry() As String) As String
System.Array.Sort(string_arry) //Sorting String Data
For Each i In string_arry
TextBox1.Text = TextBox1.Text & i & vbNewLine //Print String Data
Next
Return 0
End Function
Function sorting_num(ByVal ParamArray string_arry() As String) As Double
Dim i As Integer = 0
Dim numArray(string_arry.Length - 1) As Double
For Each num In string_arry
numArray(i) = Val(num) //Convert string to int after Assign Value
i += 1
Next
System.Array.Sort(numArray) //Sorting Number
For Each i In numArray
TextBox1.Text = TextBox1.Text & i & vbNewLine //Print Number
Next
Return 0
End Function
End Class
Comments
Post a Comment