Advertisement
Guest User

code

a guest
Nov 26th, 2014
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. Public Class Form1
  2. Structure NumberFile
  3. Dim Name As String 'Record structure for a record with 2 fields
  4. Dim Cost As String
  5. End Structure
  6. Private Sub btnProcess_Click(sender As Object, e As EventArgs) Handles btnProcess.Click
  7. Dim file As String
  8. Dim Price As NumberFile
  9. file = CurDir() & "\test.txt"
  10. FileOpen(1, file, OpenMode.Input)
  11. Do While Not EOF(1)
  12. Input(1, Price.Name)
  13. Input(1, Price.Cost)
  14. lstName.Items.Add(Price.Name)
  15. lstCost.Items.Add(Price.Cost)
  16. Loop
  17. FileClose(1)
  18. End Sub
  19.  
  20. Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
  21. Dim file As String
  22. Dim Price As NumberFile
  23. Price.Name = txtName.Text
  24. Price.Cost = txtCost.Text
  25. file = CurDir() & "\test.txt"
  26. lstName.Items.Clear()
  27. lstCost.Items.Clear()
  28. FileOpen(1, file, OpenMode.Append)
  29. WriteLine(1, Price.Name, Price.Cost)
  30. txtName.Text = ""
  31. txtCost.Text = ""
  32. txtName.Focus()
  33. FileClose(1)
  34. End Sub
  35.  
  36. Private Sub btnSearchName_Click(sender As Object, e As EventArgs) Handles Button1.Click
  37. Dim Price As NumberFile
  38. Dim file As String
  39. file = CurDir() & "\test.txt"
  40. FileOpen(1, file, OpenMode.Input)
  41. Do While Not EOF(1)
  42. Input(1, Price.Name)
  43. Input(1, Price.Cost)
  44. If txtSearchName.Text = Price.Name Then
  45. lblResult.Text = Price.Name & "owes the college money " & Price.Cost
  46. txtSearchName.Text = ""
  47. txtSearchName.Focus()
  48. End If
  49. Loop
  50. FileClose(1)
  51. End Sub
  52.  
  53.  
  54. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement