就业数据资源平台
当前位置:首页 > 笔试经验
VB编程:使用Debug.Print调试


  尽量使用Debug.Print进行调试

  在很多初学者的调试中,用MsgBox来跟踪变量值.其实用Debug.Print不仅可以达到同样的功效,而且在程序最后编译过程中,会被忽略.而MsgBox必须手动注释或删除.

  通常:

  MsgBox nName

  应该:

  Debug.Print nName




 在重复对某一对象的属性进行修改时,尽量使用With....End With

  通常:

  Form1.Height = 5000

  Form1.Width = 6000

  Form1.Caption = "This is MyLabel"

  应该:

  With Form1

  .Height = 5000

  .Width = 6000

  .Caption = "This is MyLabel"

  End With

  这种结构程序执行效率比较高,特别在循环语句里。

 


就业数据资源平台