如何返回我在VB.NET中调用的位置 [英] How do I return to where I called from in VB.NET

查看:68
本文介绍了如何返回我在VB.NET中调用的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

(我正在猜测Griff,因为他回答了我的上一个问题)我有一个例程

调用一个函数但不返回就好像我执行以下操作

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

NoDataAtPort.Enabled = True
Reply_Status = REPLY.NO_REPLY
Write_HyperTerm_Style(":FUNC VOLT:DC" & vbLf)
'need a method of getting back here
MsgBox("here!")



带有'here!'的消息框它没有显示。似乎函数被调用,VB徘徊,永远不会返回调用地点被调用的代码是


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

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")
           '



我的理解是整数枚举REPLY设置为等于REPLY.YES_REPLY它将myComPort中的数据读取到换行符,然后应从调用它的位置返回。我如何让VB回到它的调用点,我能找到的唯一一个与模糊相关的命令是Resume,它在错误处理时使用......


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...

推荐答案

Glen,如果你没有回到你的方法,那么两件事之一正在发生:

1)有些事情已经严重错误。

或者

2)Write_HyperTerm_Style方法坐在那里等待发生的事情。



所以要做的第一件事是找出哪一个:放一个断点在调用Write_HyperTerm_Style并进入函数时 - 通过Step Into跟进它,看看它是否在等待控制信号变高,或者缓冲区为空或类似。如果一切正常并且它到达返回或方法的结尾,那么尝试通过单步执行,并查看代码的结束位置。



如果方法返回但转到其他地方,则通常表示堆栈已损坏,并且通常需要外部调用.NET,通常需要使用错误的参数。
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.


这篇关于如何返回我在VB.NET中调用的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆