添加引用Microsoft Script Control
Imports MSScriptControl
Public Class Form1
Dim ScripObj As New MSScriptControl.ScriptControl
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ScripObj.Language = "VBScript"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
ScripObj.AddCode(RichTextBox1.Text)
ScripObj.Run("a", TextBox1)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
End Class
'在文本框中输入的函数
sub a(obj)
dim a ,b
a=40:b=30
if a>b then
obj.text="A>B"
else
obj.text="A<B"
end if
end sub