StringQueue collection object


/ Published in: Visual Basic
Save to your folder(s)

String FIFO class used in a production VB6 application.


Copy this code and paste it in your HTML
  1. ' This is a First in First Out structure for strings
  2.  
  3. Option Explicit
  4. Private sColl As Collection
  5. Private curIndex As Integer
  6. Private Sub Class_Initialize()
  7. Set sColl = New Collection
  8. curIndex = 0
  9. End Sub
  10. Private Sub Class_Terminate()
  11. Set sColl = Nothing
  12. End Sub
  13. Public Property Get Count() As Long
  14. Count = sColl.Count
  15. End Property
  16. Public Property Get NextValue() As String
  17. NextValue = CStr(sColl.item(sColl.Count))
  18. End Property
  19. Public Sub Push(ByVal value As String)
  20. sColl.Add value
  21. End Sub
  22. Public Function Pop() As String
  23. Dim poppedval As String
  24. poppedval = CStr(sColl.item(sColl.Count))
  25. sColl.Remove (sColl.Count)
  26. Pop = poppedval
  27. End Function
  28. Public Sub Clear()
  29. 'clears all elements
  30. Do Until sColl.Count = 0
  31. sColl.Remove (0)
  32. Loop
  33. End Sub

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.