BP Forums
Code within code - Printable Version

+- BP Forums (https://bpforums.info)
+-- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=55)
+--- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=56)
+---- Forum: VB.NET (Visual Basic 2010/2008) (https://bpforums.info/forumdisplay.php?fid=8)
+----- Forum: Code Snippets (https://bpforums.info/forumdisplay.php?fid=18)
+----- Thread: Code within code (/showthread.php?tid=445)



Code within code - brandonio21 - 01-07-2012

Here is just a little tip for you guys, if you ever want to store a snippet of code within a variable, you can use the following syntax.
Code:
<code>
</code>

So for example,
Code:
Dim c = <code>
Messagebox.Show("Hello!")
</code>

This will actually store the code to display a messagebox with the text of 'Hello' within the c variable. This is very useful if you would like to develop some sort of plugin system for your application.

I am not too familiar on how executing that variable actually works, but here is a code snippet that shows the execution of code stored within a variable.
<!-- m --><a class="postlink" href="http://pastebin.com/CKfD7nRz">http://pastebin.com/CKfD7nRz</a><!-- m -->