作者 主題: 分享: vb .net debugging 小技巧/coding template  (閱讀 6255 次)

0 會員 與 1 訪客 正在閱讀本文。

小徒兒

  • 鑽研的研究生
  • *****
  • 文章數: 622
    • 檢視個人資料
vb ide can coding on the break mode, but vb .net can not.

dubug run key
-------------
- run/start (F5)
- run step (F11)
- run setp not enter in the sub (F10)
- 中斷點 (Ctrol +B)
- stop run ( Ctrol+Alt+Break)

windows
--------
* command (命令)
  -one samll vb commnad line
  - ? variableabc (use ? in vb.net instead of print in vb)

* call stack ( 呼叫堆疊)

*Watch window (監看視窗)
  -add new watch

*breakpoint
   - Breakpoint/ filter/ condition, edit by right click
   
   
*output
   - Debug.writeline("print every msg in line")
   - Debug.write("all the msg will connect in one line")
   - Debug.writelineif (Variable >0 , "this variable is bigger than 0")
   - debug.assert (true, "assert means if the condition is true, it will not show")
   - debug.assert (false, "so this line will be shown by the dialog box")


*auto window(自動變數)
   - view all now automatically variable

*local window(區域變數)
   - view all local variable


代碼: [選擇]
Try
            Debug.WriteLine("Codes Area....")
            Dim intOverflow As Integer = 1234567890
            Dim intA As Integer = 0
            Dim intB As Integer = 0
            intA = intA / intB

        Catch eh As DivideByZeroException
            Debug.WriteLine("Catch Area: Divide By Zero Error")
        Catch eh As OverflowException
            Debug.WriteLine("Catch Area:Overflow Error")

        Finally
            Debug.WriteLine("Finally Area")

        End Try



代碼: [選擇]

[Private|public] [sub|function] Example() [as VarialbeType]
[b]On error Goto [/b] [i]Label[/i]

'your codes

Exit [Sub|Function]

Label:

   'exception handeling

    [Resume|Resume Next|Resume LineNubmer|Err.Raise]
   
End [Sub|Function]



 -resume means resume to the error happening codes and keep running
 - resume next runs from the next code line
 - resume label run from the label
 - err.raise number:=number using code to the upper level error handling