日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

[ZZ]Debug VBScript with Visual Studio

發布時間:2023/12/15 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 [ZZ]Debug VBScript with Visual Studio 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?

http://blog.theopensourceu.com/2009/05/debug-vbscript-with-visual-studio/

?

For a project that I work on at at my primary employer, we use VBScript inside of DTS packages. Until this project, I’ve not had too much experience with VBScript. What I’ve found most frustrating about the language is the inability to step though the code… until a recent discovery. I’ve found that if I save the target code to my local machine as a VBS file and execute it with WScript.exe, I can attach a debugger to it.

I’ve discovered this by poking around and I don’t know too much about WScript.exe. I’m sure if you Google it, you can find more about it.

For this to work, you’ll need a copy of Visual Studio installed. I am not sure if any of the express editions will work. Drop a line in the comments if you find it will. As a quick walk though:

  • Save your code as a VBS file. Don’t forget to call Main (or your main) function as wscript won’t automatically call main.
  • Open a command prompt.
  • Navigate to the location of the file.
  • Type: WScript.exe FileName.vbs //D //X
  • You should be prompted to select a debugger, select a new instance of either Visual Studio 2003, 2005 or 2008.
  • Visual studio will open up and break at the very first line.
  • Step though the code.
  • For an example, save the following as “Example.vbs” on your desktop.

    ?

    MsgBox "Starting Script!" Dim i : i = 0 Const C_Max = 100 Dim sPrimeNumberList : sPrimeNumberList = "Prime Numbers: " & vbCrLf For i = 0 to C_Max If IsNumberPrimeNumber(i) ThensPrimeNumberList = sPrimeNumberList & cStr(i) & ", " EndIf Next MsgBox sPrimeNumberList MsgBox "Script Completed."PublicFunction IsNumberPrimeNumber(ByVal iNumber) Dim bIsPrime : bIsPrime = True For j = 2 To iNumber\2bIsPrime = iNumber Mod j > 0 IfNot bIsPrime ThenExitFor Next IsNumberPrimeNumber = bIsPrime EndFunction

    ?

    ?

    Open a command prompt and navigate to your desktop:

    Command Prompt for DebuggingVBScript from Visual Studio

    Once there, type in the following:

    ?

    1 wscript Example.vbs //D //X

    ?

    You should then be presented with a dialog similar to the following:

    Visual StudioDebuggingVBScript

    Once you make a selection, you should get something like the following:

    DebuggingVBScript from Visual Studio

    From here, I’ll assume you are familiar enough with Visual Studio to play with the debugger and learn how it works. When debuggingVBScript, I’ve found that you don’t have all the options that you might be used to such as Step In To, but for me simply having this much is a life saver.

    To get around the step-in-to thing, I simply use Run to Cursor. It works like a charm.

    Update: I just found that (at least on this computer) and in Visual Studio 2003, I have all my standard code-stepping buttons available. I’m not sure why on my work computer I only have Step-Over but either way, this is still a life saver.

    轉載于:https://www.cnblogs.com/pegasus923/archive/2011/01/12/1933731.html

    總結

    以上是生活随笔為你收集整理的[ZZ]Debug VBScript with Visual Studio的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。