帮助将vbscript转换为vb.net代码 [英] Help with converting vbscript to vb.net code

查看:63
本文介绍了帮助将vbscript转换为vb.net代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个小的Activex脚本(vbscript),用于DTS 2000程序包.我需要将此VB脚本转换为VB.net脚本,以便可以将程序包迁移到更高版本(2008).谁能给我一些有关如何将vbscript转换为vb.net代码的见解?可以自动完成吗?

感谢您的答复.

Hi all,

I have a small activex script(vbscript) which is used in the DTS 2000 package. I need to convert this VB script to VB.net script so that I can migrate the package to later version (2008). Can any one give me some insight of how to convert a vbscript into vb.net code? can it be done automatically?

Thanks for your replies.

推荐答案

我不知道有没有做过的工具",如果那样的话.坦白说,将vbscript从vbscript粘贴到开发环境并更正语法,手动转换vbscript并不难.
I dont know of any "tools" that do it, if thats what your after. Honestly vbscript to vb.net shouldn''t be that hard to manually convert by pasting it from your vbscript into your development enviroment and correcting the syntax.


函数PUT_MESSAGE(strQueue_Name,strMessage)

昏暗的fileSysObj,fileObj,fileStr,fileVal
昏暗的strEnvName,strQueueName
昏暗的strQueueMgr,strQueueVal
昏暗的blnCheck

fileVal =修剪(strMessage)

''''将文件转换为字符串
设置fileSysObj = CreateObject("Scripting.FileSystemObject")
设置fileObj = fileSysObj.OpenTextFile(fileVal,1)
fileStr = fileObj.ReadAll
''''打印完整字符串为:"& fileStr

''检索环境变量
strEnvName = Environment.Value(环境")
报告micGeneral,"PUT_MESSAGE",环境变量如下:& strEnvName,详细信息

''''检索特定于环境的队列管理器
选择案例strEnvName
案例"BAT"''''业务验收测试
strQueueMgr = Environment.Value("BAT_MQ_QUEUE_MGR")
案例"AB"''''自动化版本
strQueueMgr = Environment.Value("AB_MQ_QUEUE_MGR")
否则,打印找不到队列连接信息"
结束选择

''''构建队列名称
strQueueName = strEnvName& "_"& strQueue_Name
REPORTING micGeneral,"PUT_MESSAGE",搜索变量如下:& strQueueName,详细信息

strQueueVal = Environment.Value(strQueueName)
REPORTING micGeneral,"PUT_MESSAGE",队列名称变量如下:& strQueueVal,详细信息

''''设置MQServer值
''''''''设置MQServer ="MQ.CLT.CHL.MACTOR/TCP/10.64.68.115(2414)"

''初始化
设置MQSession = Nothing
设置QManager = Nothing

''''创建MQAX200.dll会话
设置MQSession = CreateObject("MQAX200.MQSession")

设置QManager = MQSession.AccessQueueManager("MQASW1")
''''STGPQM1-系统测试
''''ILMS5GP1-新的自动化环境
''''MQAGP1-BAT


''''连接到适当的队列管理器
''''''设置QManager = MQSession.AccessQueueManager(strQueueMgr)

''检查Queuemanager是否已连接
blnCheck = QManager.isConnected()
''''MsgBox检查

正在报告micGeneral,"PUT_MESSAGE",与& strQueueMgr& "被激活:& blnCheck,详细信息

strQueueVal ="SWH_SWIFTIN_SAA"

''昏暗积分
''''访问队列
设置队列= QManager.AccessQueue(strQueueVal,MQOO_INPUT_AS_Q_DEF + MQOO_OUTPUT)
''intcount = Queue.CURDEPTH

''将消息放入队列
设置WriteMessage = MQSession.AccessMessage()
''消息
WriteMessage.MessageData = fileStr
设置PutOptions = MQSession.AccessPutMessageOptions()
''将消息放入队列
调用Queue.Put(WriteMessage,PutOptions)
正在报告micGeneral,"PUT_MESSAGE",消息"& fileStr& 已写入以下队列:"& strQueue_Name,详细信息

''关闭队列
Queue.Close

''断开QueueManager的连接
QManager.Disconnect

正在报告micGeneral,"PUT_MESSAGE",正在关闭QManager连接.",详细信息

结束功能
Function PUT_MESSAGE(strQueue_Name, strMessage)

Dim fileSysObj, fileObj, fileStr, fileVal
Dim strEnvName, strQueueName
Dim strQueueMgr, strQueueVal
Dim blnCheck

fileVal = Trim(strMessage)

''''Convert file to a string
Set fileSysObj = CreateObject("Scripting.FileSystemObject")
Set fileObj = fileSysObj.OpenTextFile(fileVal,1)
fileStr = fileObj.ReadAll
''''Print "Full string is: " & fileStr

''Retrieve the environment variable
strEnvName = Environment.Value("ENVIRONMENT")
REPORTING micGeneral, "PUT_MESSAGE", "The environment variable is as follows: " & strEnvName, DETAIL

''''Retrieve the Environment specific queue manager
Select Case strEnvName
Case "BAT" '''' Business Acceptance Test
strQueueMgr = Environment.Value("BAT_MQ_QUEUE_MGR")
Case "AB" '''' Automation Build
strQueueMgr = Environment.Value("AB_MQ_QUEUE_MGR")
Case Else Print "Could not find queue connection information"
End Select

''''Build queue name
strQueueName = strEnvName & "_" & strQueue_Name
REPORTING micGeneral, "PUT_MESSAGE", "The search variable is as follows: " & strQueueName, DETAIL

strQueueVal = Environment.Value(strQueueName)
REPORTING micGeneral, "PUT_MESSAGE", "The queue name variable is as follows: " & strQueueVal, DETAIL

''''Set MQServer value
'''''''' Set MQServer = "MQ.CLT.CHL.MACTOR/TCP/10.64.68.115(2414)"

''Initialise
Set MQSession = Nothing
Set QManager = Nothing

'' ''Creating the MQAX200.dll Session
Set MQSession = CreateObject("MQAX200.MQSession")

Set QManager = MQSession.AccessQueueManager("MQASW1")
''''STGPQM1 - System Test
''''ILMS5GP1 - New Automation Environment
''''MQAGP1 - BAT


''''Connect to appropriate Queue Manager
'''''' Set QManager = MQSession.AccessQueueManager(strQueueMgr)

'' Checking Whether Queuemanager is connected or not
blnCheck = QManager.isConnected()
'''' MsgBox Check

REPORTING micGeneral, "PUT_MESSAGE", "The connection to " & strQueueMgr & " is activated: " & blnCheck, DETAIL

strQueueVal = "SWH_SWIFTIN_SAA"

'' Dim intcount
'' '' Accessing the Queue
Set Queue = QManager.AccessQueue(strQueueVal, MQOO_INPUT_AS_Q_DEF + MQOO_OUTPUT )
'' intcount=Queue.CURDEPTH

''Put message in Queue
Set WriteMessage = MQSession.AccessMessage()
'' Message
WriteMessage.MessageData = fileStr
Set PutOptions = MQSession.AccessPutMessageOptions()
'' Putting message in Queue
Call Queue.Put(WriteMessage, PutOptions)
REPORTING micGeneral, "PUT_MESSAGE", "The message " & fileStr & " has been written to the following queue: " & strQueue_Name, DETAIL

'' Closing the Queue
Queue.Close

'' Disconnecting the QueueManager
QManager.Disconnect

REPORTING micGeneral, "PUT_MESSAGE", "Closing QManager connection.", DETAIL

End Function


这篇关于帮助将vbscript转换为vb.net代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆