How to implement queues in vb 6.0
-
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
-
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
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.
-
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.
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.
-
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.
-
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
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
-
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
-
There is no explcit queue. You could use an array instead. Good luck with your demo tomorow: Didi
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
-
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
-
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
There are collections in VB6, try:
Option Explicit
Private queue As Collection
Private Sub Class_Initialize()
Set queue = New Collection
End SubPublic Sub Enqueue(newItem As String)
queue.Add newItem
End SubPublic Function Dequeue() As String
Dim ret As String
ret = queue.item(1)
queue.Remove 1Dequeue = ret
End Function
Panic, Chaos, Destruction. My work here is done.
-
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.
-
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.
-
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
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.
-
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.