Click here to Skip to main content
15,867,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,
(I'm guessing Griff as he answered my last Question) I have a routine
that calls an a function but does not return as if I do the following
VB
NoDataAtPort.Enabled = True
Reply_Status = REPLY.NO_REPLY
Write_HyperTerm_Style(":FUNC VOLT:DC" & vbLf)
'need a method of getting back here
MsgBox("here!")

The message box with 'here!' in it is not displayed. It seems like the function is called and VB wanders off never to return to the calling place the code that gets called is
VB
While (Reply_Status = REPLY.NO_REPLY)
           TmrNoDataAtPort.Enabled = True
           Application.DoEvents()
       End While
       If (Reply_Status = REPLY.TIMEOUT_REPLY) Then
           Data_Back = "TIMEOUT"
           rtbIncoming.Text = "TIMEOUT"
           Return
       ElseIf (Reply_Status = REPLY.YES_REPLY) Then
           Data_Back = myComPort.ReadTo(vbLf)
           Return
           If (Data_Back.Substring(0, 1) = Data_Back.Substring(1, 1)) Then
               Return
           End If
       ElseIf (Data_Send.Substring(0, 1) = "E") Then
           MessageBox.Show("ERROR Code From ATE")
           '

my understanding is the Integer Enum REPLY is set to equal REPLY.YES_REPLY it reads the data from myComPort to a Line Feed and then should return from where it was called from. How do I get VB to go back to its calling point, the only other command I can find that is even vaguely related is Resume which is used when error handling...
Posted

1 solution

Glen, if you aren't getting back to your method then one of two things is happening:
1) Something Has Gone Seriously Wrong.
Or
2) The Write_HyperTerm_Style method is sitting there waiting for something to happen.

So the first thing to do is find out which: Put a breakpoint on the call to Write_HyperTerm_Style and step into the function - follow it through with "Step Into" and see if it is waiting for a control signal to go high, or a buffer to empty or similar. If it all works and it gets to a "return" or the end of the method then try following that through with single step as well and see where your code ends up.

If the method returns but goes elsewhere, it's normally a sign that the stack is corrupted, and that often requires external-to-.NET calls, frequently with the wrong parameters.
 
Share this answer
 
Comments
glennPattonWork3 10-Feb-14 12:47pm    
Hi, Another day of WTF how do you do this in VB done. I have the ability to send multiple commands at last(!) and the TIMEOUT working properly! (I think) Basic easy my ****
OriginalGriff 10-Feb-14 13:59pm    
Trust me, you can c***-up just as badly in C#! :laugh:
glennPattonWork3 11-Feb-14 4:19am    
Don't worry, I know, I have, at least I know where the bodies are buried and where the shovel is!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900