Private Sub BuildDefaultSource() Dim mCodeBuilder As CodeBuilder = New CodeBuilder With mCodeBuilder .AppendCode("Imports System") .AppendCode("Imports System.Data") .AppendCode("Imports System.Math") .AppendCode("Imports Microsoft.VisualBasic") .AppendCode() .AppendCode("Public Class tmpClass") .AppendCode(" Public Function GetExpressionValue() As Object") .AppendCode(" Dim Result As Object") .AppendCode(" Result={0}") '这里传入表达式 .AppendCode(" Return Result") .AppendCode(" End Function") .AppendCode("End Class") End With Me.m_Source = mCodeBuilder.ToString End Sub '//指定源代码 Public Sub SetSource(ByVal Source As String) Me.m_Source = Source Me.m_Compiled = False Me.m_Is_Default = False End Sub '//从指定文件中读取源代码 Public Sub GetSourceFormFile(ByVal SourceFileName As String) Dim mCodeBuilder As CodeBuilder = New CodeBuilder mCodeBuilder.AppendFromFile(SourceFileName) Me.m_Source = mCodeBuilder.ToString Me.m_Compiled = False Me.m_Is_Default = False End Sub '//编译 Public Sub Complile() If Me.m_Source = "" Then Me.BuildDefaultSource() End If If Me.m_Is_Default Then |