**Must Use Visual Basic 2008!! I already run this in VB2003.**
**Object**: Create an "On-the-fly" compilation and execution of internally generated code.
**Problem**: I have a program which writes a piece of code, which can be modified by the user.? After the user modifies it, the new code must be compiled "on-the-fly" and then executed.
If there are errors, the errors, their line numbers, and the line of code itself, must be displayed in a ListView or grid.
**Setup:**
Using VisualBasic 2008 -
1) Make a form with a menu that has two options,? "compile" and "execute" , a Rich Text box for editing and a listview or flexgrid.
In the? RichText box, add the following code, which consists of a function? and a class definition, as in the following code:
function Add() as decimal
? dim c as new clsAdd
? dim rtn as decimal
? rtn=[login to view URL]
? msgbox("rtn=" & rtn)
end function
public class clsAdd()
? ? ? ? function add() as decimal
? ? ? ? ? ? ? ? ? ? ? ? return 2.5
? ? ? ? end function
end class
2) Take this code from the RichTextBox and then add/inject whatever additional code is needed to make this into compileable source code and an executable which executes the function Add.
3) Enable the user to then compile it.? If no errors, then enable the user to execute it.
4) If errors, place each error, error line and error number into a listview or flex grid