Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub btnSort_Click(sender As Object, e As EventArgs) Handles btnSort.Click
- Dim Count As Integer
- Dim Count2 As Integer
- Dim Temp1 As Integer
- Dim Temp2 As Integer
- FileOpen(1, StockFilename, OpenMode.Random,,, Len(AddStock))
- StockNumberOfRecords = LOF(1) / Len(AddStock)
- Dim StockQuantity(StockNumberOfRecords) As Integer
- lstStock.Items.Clear()
- lstStock.Items.Add(String.Format(MyStockformat, "StockID", "Name", "Description", "Sell For", "Qty"))
- For Count = 0 To StockNumberOfRecords - 1
- FileGet(1, AddStock, Count + 1)
- StockQuantity(Count) = AddStock.Qty
- Next
- For Count = 0 To StockNumberOfRecords - 1
- For Count2 = 0 To StockNumberOfRecords - 1
- If StockQuantity(Count) > StockQuantity(Count2) Then
- Temp1 = StockQuantity(Count)
- Temp2 = StockQuantity(Count2)
- StockQuantity(Count) = Temp2
- StockQuantity(Count2) = Temp1
- End If
- Next
- Next
- FileClose(1)
- FileOpen(1, StockFilename, OpenMode.Random,,, Len(AddStock))
- For Count = 0 To StockNumberOfRecords - 1
- For Count2 = 0 To StockNumberOfRecords - 1
- FileGet(1, AddStock, Count2 + 1)
- If AddStock.Qty = StockQuantity(Count) Then
- lstStock.Items.Add(String.Format(MyStockformat, AddStock.StockID, AddStock.Name, AddStock.Description, AddStock.SellFor, AddStock.Qty))
- End If
- Next
- Next
- FileClose(1)
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement