Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to implement queues in vb 6.0

How to implement queues in vb 6.0

Scheduled Pinned Locked Moved Visual Basic
csharpcomdata-structurestutorial
13 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U User 3055467

    Hi I am using VB 6.0. I am working on an application involving Com port. I need to send messages to com port continously and when I recieve data from the other end i need to perform another action. So I should put the data to be sent in a queue and when I recieve response from the other end I should remove first element in the queue and process that. using queues is an appropriate one. I can't use .NET now. In .NET it's very simple using System.Collections.Queue. Thanks in advance

    C Offline
    C Offline
    Christian Graus
    wrote on last edited by
    #2

    Member 3057887 wrote:

    I am using VB 6.0.

    Why would you do such a thing ? Have you lost a bet ?

    Christian Graus Driven to the arms of OSX by Vista. Please read this[^] if you don't like the answer I gave to your question. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.

    U J 2 Replies Last reply
    0
    • C Christian Graus

      Member 3057887 wrote:

      I am using VB 6.0.

      Why would you do such a thing ? Have you lost a bet ?

      Christian Graus Driven to the arms of OSX by Vista. Please read this[^] if you don't like the answer I gave to your question. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.

      U Offline
      U Offline
      User 3055467
      wrote on last edited by
      #3

      Hi Thanks for replying so soon I did not bet at all. The application is already developed in Vb 6.0. To convert it into .NET it takes some time. But we dont have much time as we have demo tomorow.

      D 1 Reply Last reply
      0
      • U User 3055467

        Hi Thanks for replying so soon I did not bet at all. The application is already developed in Vb 6.0. To convert it into .NET it takes some time. But we dont have much time as we have demo tomorow.

        D Offline
        D Offline
        DidiKunz
        wrote on last edited by
        #4

        There is no threading support in VB6. For a workaround (if you port your app to .NET later) I would try something with a timer control, that pools your serial. Thats NOT good practice, but probably a quick and dirty way... Regards: Didi

        U 1 Reply Last reply
        0
        • D DidiKunz

          There is no threading support in VB6. For a workaround (if you port your app to .NET later) I would try something with a timer control, that pools your serial. Thats NOT good practice, but probably a quick and dirty way... Regards: Didi

          U Offline
          U Offline
          User 3055467
          wrote on last edited by
          #5

          I'm trying to do the same. All I need is how to implement queues in vb 6.0. Is there any way like System.Collections.Queue in .NET. I want to put all the messages to be sent into a queue. when the comport receives response from the other end I will take out the first element in the queue and use that. regards

          D N 2 Replies Last reply
          0
          • U User 3055467

            I'm trying to do the same. All I need is how to implement queues in vb 6.0. Is there any way like System.Collections.Queue in .NET. I want to put all the messages to be sent into a queue. when the comport receives response from the other end I will take out the first element in the queue and use that. regards

            D Offline
            D Offline
            DidiKunz
            wrote on last edited by
            #6

            There is no explcit queue. You could use an array instead. Good luck with your demo tomorow: Didi

            U 1 Reply Last reply
            0
            • D DidiKunz

              There is no explcit queue. You could use an array instead. Good luck with your demo tomorow: Didi

              U Offline
              U Offline
              User 3055467
              wrote on last edited by
              #7

              Hi thanks a lot. array size is fixed. if i use redim it is intializing every time. the code should be in such a way that when the timer fires the msg to be sent should be appended to the list of previous msgs. regards

              D 1 Reply Last reply
              0
              • U User 3055467

                Hi thanks a lot. array size is fixed. if i use redim it is intializing every time. the code should be in such a way that when the timer fires the msg to be sent should be appended to the list of previous msgs. regards

                D Offline
                D Offline
                DidiKunz
                wrote on last edited by
                #8

                ...use ReDim Preserve and it will not reinitialze. Regards: Didi

                N 1 Reply Last reply
                0
                • U User 3055467

                  I'm trying to do the same. All I need is how to implement queues in vb 6.0. Is there any way like System.Collections.Queue in .NET. I want to put all the messages to be sent into a queue. when the comport receives response from the other end I will take out the first element in the queue and use that. regards

                  N Offline
                  N Offline
                  Nagy Vilmos
                  wrote on last edited by
                  #9

                  There are collections in VB6, try:

                  Option Explicit

                  Private queue As Collection

                  Private Sub Class_Initialize()
                  Set queue = New Collection
                  End Sub

                  Public Sub Enqueue(newItem As String)
                  queue.Add newItem
                  End Sub

                  Public Function Dequeue() As String
                  Dim ret As String
                  ret = queue.item(1)
                  queue.Remove 1

                  Dequeue = ret
                  

                  End Function


                  Panic, Chaos, Destruction. My work here is done.

                  1 Reply Last reply
                  0
                  • D DidiKunz

                    ...use ReDim Preserve and it will not reinitialze. Regards: Didi

                    N Offline
                    N Offline
                    Nagy Vilmos
                    wrote on last edited by
                    #10

                    ReDim Preserve is a painful solution, the memory usage is nasty as you need to have allocated both the old and new memory at the same time.


                    Panic, Chaos, Destruction. My work here is done.

                    D 1 Reply Last reply
                    0
                    • N Nagy Vilmos

                      ReDim Preserve is a painful solution, the memory usage is nasty as you need to have allocated both the old and new memory at the same time.


                      Panic, Chaos, Destruction. My work here is done.

                      D Offline
                      D Offline
                      DidiKunz
                      wrote on last edited by
                      #11

                      Yes, you are right, but we were talking about a dirty easy solution to save a presetation appointment tomorow. The guy is going to port the solution to .NET later. I never saied that this is good programming practice. Regards: Didi

                      N 1 Reply Last reply
                      0
                      • D DidiKunz

                        Yes, you are right, but we were talking about a dirty easy solution to save a presetation appointment tomorow. The guy is going to port the solution to .NET later. I never saied that this is good programming practice. Regards: Didi

                        N Offline
                        N Offline
                        Nagy Vilmos
                        wrote on last edited by
                        #12

                        I've seen so much 'quick and dirty for a demo' go into production code that I avoid it like the plague.


                        Panic, Chaos, Destruction. My work here is done.

                        1 Reply Last reply
                        0
                        • C Christian Graus

                          Member 3057887 wrote:

                          I am using VB 6.0.

                          Why would you do such a thing ? Have you lost a bet ?

                          Christian Graus Driven to the arms of OSX by Vista. Please read this[^] if you don't like the answer I gave to your question. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.

                          J Offline
                          J Offline
                          Jon_Boy
                          wrote on last edited by
                          #13

                          Zing!

                          "There's no such thing as a stupid question, only stupid people." - Mr. Garrison

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups