53. Sorting Arrays - Visual Basic 2017

preview_player
Показать описание
Sorting Arrays - (See Description for Procedure and source code)

It is sometimes useful to be able to sort an array. You might find this useful when you display data to users in a manner they can easily search or when you need to evaluate data logically.

This Try It Out demonstrates how you can sort an array alphabetically.

1. Return to the Forms Designer in the Array Demo project (Tutorial 52) and add another Button control. Set its Name property to btnSortingArrays and its Text property to Sorting Arrays.

2. Double‐click the button and add the following bolded code to its Click event handler:

Private Sub btnSortingArrays_Click(sender As Object,
e As EventArgs) Handles btnSortingArrays.Click
'Clear the list
ClearList()
'Sort the array
Array.Sort(strFriends)
'List your friends
AddItemsToList(strFriends)
End Sub

3. Run the project and click the button. You’ll see the ListBox on your form populated with the names from your array sorted alphabetically.

Please share and Subscribe for Updates.

Source: Beginning Visual Basic 2015 by Bryan Newsome
Рекомендации по теме
welcome to shbcf.ru