'//计算结果 Dim Result As Object = m_MethodInfo.Invoke(m_tmpClass, Nothing)
'表达式不同时要重新编译 Me.m_Compiled = False Return Result End Function End Class '//格式生成或读取代码的类 Public Class CodeBuilder Private _StringBuilder As System.Text.StringBuilder '//格式,{0}为空格数,{1}代码字串,最后加回车换行 Private Const CodeFormat As String = "{0}{1}" & ControlChars.CrLf Sub New() _StringBuilder = New System.Text.StringBuilder End Sub Public Overloads Sub AppendCode() _StringBuilder.AppendFormat(CodeFormat, Space(0), Space(0)) End Sub Public Overloads Sub AppendCode(ByVal CodeString As String) _StringBuilder.AppendFormat(CodeFormat, Space(0), CodeString) End Sub Public Overloads Sub AppendCode(ByVal CodeFloor As Integer, ByVal CodeString As String) _StringBuilder.AppendFormat(CodeFormat, Space(CodeFloor * 4), CodeString) End Sub '//直接从已有vb文件中读取代码 Public Sub AppendFromFile(ByVal FileName As String) If Not System.IO.File.Exists(FileName) Then MsgBox(FileName & "不存在.") Exit Sub End If Dim tmpStr As String Dim fs As System.IO.FileStream |