converting vbscript to | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

converting vbscript to

How would I convert the following code to Thanks…
‘ Visual Basic ActiveX Script
‘************************************************************************ Function Main() Dim objFSO, objFolder, colFiles, strFilesExists
DTSGlobalVariables("ImportDirectoryPath").Value = DTSGlobalVariables("FileLocation").Value SET objFSO = CreateObject("Scripting.FileSystemObject")
SET objFolder = objFSO.GetFolder(DTSGlobalVariables("FileLocation").Value)
SET colFiles = objFolder.Files
strFilesExists = "NO" If colFiles.Count > 0 Then
For Each objFile In colFiles
‘Look to see if files exists
IF UCASE(Left(objFile.Name, 3)) = "RCC" THEN ‘If atleast one exists move on
DTSGlobalVariables("FileName").Value = objFile.Name
DTSGlobalVariables("FileCreateDate").Value = Mid( DTSGlobalVariables("FileName").Value , 4 , 10 )
DTSGlobalVariables("ConnectionString").Value =DTSGlobalVariables("FileLocation").Value + "" + objFile.Name
strFilesExists = "YES" Exit For
End IF If strFilesExists = "NO" Then
Main = DTSTaskExecResult_Failure
Main = DTSTaskExecResult_Success
End if End Function
I think with visual studio .net, there is a vb to .net code coversion utility.
Still i feel you will be creating SSIS package for this and there is still option to execute vbscript and also to import visualbasic libraries. Considering the lines of code, i guess you are better off writing this in .net script on your own instead of running it as vbscipt in SSIS.
Thanks for the fast reply, ranjitjain. Would you know where this tool is in the Microsoft Visual Studio for Applications environment that ships with SQL Server 2005? Or will I have to use visual
In SSIS you can also add your existing vbscript as activex script task and then select the script language.
Also long time back i had imported my vb code into .net
but i dont remember how i did it
I found that option even under visual studio 2005.
Open Visual studio,
click on Open and then you will find convert option.
Click on convert and then use vb upgrade wizard