Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. Private Sub btnSort_Click(sender As Object, e As EventArgs) Handles btnSort.Click
  2. Dim Count As Integer
  3. Dim Count2 As Integer
  4. Dim Temp1 As Integer
  5. Dim Temp2 As Integer
  6.  
  7. FileOpen(1, StockFilename, OpenMode.Random,,, Len(AddStock))
  8. StockNumberOfRecords = LOF(1) / Len(AddStock)
  9. Dim StockQuantity(StockNumberOfRecords) As Integer
  10.  
  11. lstStock.Items.Clear()
  12. lstStock.Items.Add(String.Format(MyStockformat, "StockID", "Name", "Description", "Sell For", "Qty"))
  13.  
  14. For Count = 0 To StockNumberOfRecords - 1
  15. FileGet(1, AddStock, Count + 1)
  16. StockQuantity(Count) = AddStock.Qty
  17. Next
  18.  
  19. For Count = 0 To StockNumberOfRecords - 1
  20. For Count2 = 0 To StockNumberOfRecords - 1
  21. If StockQuantity(Count) > StockQuantity(Count2) Then
  22. Temp1 = StockQuantity(Count)
  23. Temp2 = StockQuantity(Count2)
  24.  
  25. StockQuantity(Count) = Temp2
  26. StockQuantity(Count2) = Temp1
  27. End If
  28. Next
  29. Next
  30.  
  31. FileClose(1)
  32. FileOpen(1, StockFilename, OpenMode.Random,,, Len(AddStock))
  33.  
  34.  
  35. For Count = 0 To StockNumberOfRecords - 1
  36. For Count2 = 0 To StockNumberOfRecords - 1
  37. FileGet(1, AddStock, Count2 + 1)
  38. If AddStock.Qty = StockQuantity(Count) Then
  39. lstStock.Items.Add(String.Format(MyStockformat, AddStock.StockID, AddStock.Name, AddStock.Description, AddStock.SellFor, AddStock.Qty))
  40. End If
  41. Next
  42. Next
  43.  
  44. FileClose(1)
  45. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement