Friday, April 4, 2014

Convert vbscript code to vb.net

Create vb.net console project

below blue is old vbscript, yellow is converted code

Add reference to Interop.IWshRuntimeLibrary

Imports IWshRuntimeLibrary

 'objFSO = CreateObject("Scripting.FileSystemObject")

Dim objFSO As FileSystemObject = New FileSystemObject

 ' WshNetwork = WScript.CreateObject("WScript.Network")

 Dim WshNetwork As WshNetwork = New WshNetwork

move  two yellow lines below to above Main to make it globally accessible

Module Module1
    Dim objFSO As FileSystemObject = New FileSystemObject
    Dim WshNetwork As WshNetwork = New WshNetwork
    Sub Main()

may want to change objFSO to m_objFSO and WshNetwork to m_wshNetwork

No comments:

Post a Comment