Answer to Question #15240 in Visual Basic for Whiteangel

Question #15240
how to sort in ascending order there's a two button one for the input from the user's from the input box and it print the numbers in the picture box and the one button is for sorting the numbers from user's input and it will display in picture box too..
Thanks
1
Expert's answer
2012-10-01T10:16:43-0400
Public Class Form1
Dim str_sort() As String
Dim Graph As Graphics
Dim Drawbitmap As Bitmap
Dim Brush As New Drawing.SolidBrush(Color.Black)
Dim myFont As Font = New Font("Times new roman", 28, FontStyle.Bold, GraphicsUnit.Point)
&
&
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
& Dim str As String
#039;Input sting from text box
& str = InputBox("Enter numbers", "Enter Nambers").ToString()
#039;Split string to array by space
& str_sort = Split(str, " ")
& Dim out = "Unsort: " + str
#039;Print string into PictureBox
& Drawbitmap = New Bitmap(PictureBox1.Width, PictureBox1.Height)
& Graph = Graphics.FromImage(Drawbitmap)
& PictureBox1.Image = Drawbitmap
& Graph.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
& Graph.DrawString(out, myFont, Brush, PictureBox1.Location)
#039;End Print string into PictureBox
&
End Sub
&
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
#039;Sort array acsessing order
& str_sort.Sort(str_sort)
&
#039;Print array into PictureBox
& Dim out = "Sort: "
& For Each s As String In str_sort
out = out + s + " "
& Next
&
& Drawbitmap = New Bitmap(PictureBox1.Width, PictureBox1.Height)
& Graph = Graphics.FromImage(Drawbitmap)
& PictureBox1.Image = Drawbitmap
& Graph.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
& Graph.DrawString(out, myFont, Brush, PictureBox1.Location)
#039;End Print array into PictureBox
End Sub
End Class

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS