这是产生错误的示例代码。我过去在 VB 项目中使用过 MSscript,这些项目正在运行。
报告的错误是:“从数字转换时,值必须是小于无穷大的数字”
或者,如果有人有另一种建议的方式来轻松地将脚本添加到项目中。
Private Sub Run_Script()
Dim scriptEngine As New MSScriptControl.ScriptControl()
Dim TestClass As New Sample
Dim ScriptCode As String
scriptEngine.Language = "VbScript"
scriptEngine.AddObject("Test", TestClass, True)
ScriptCode = "MsgBox ""tests"" "
scriptEngine.AddCode(ScriptCode)
End Sub
End Class
Public Class Sample
Public Sub Test()
MessageBox.Show("This is a test")
End Sub
End Class