-4

I have a project in visual studio 2013, using vb.net and I'd like to know how to import code directly from a text file and run it as code in the program.

I know this seems odd but it needs to be this way. Also I can't use a string builder and as i'm using vs it has a compiler built in.

Any help is appreciated

thanks in advance.

  • Have a look at this http://stackoverflow.com/questions/4181668/execute-c-sharp-code-at-runtime-from-code-file it's in c# but should be easy enough to convert to VB.NET – JaggenSWE May 19 '16 at 11:41
  • thanks but I'm really not good at converting this sort of stuff so an answer in VB.net itself would be better. – Joshua Thomas May 19 '16 at 11:45
  • 1
    http://stackoverflow.com/questions/21379926/load-vb-net-code-from-txt-file-and-execute-it-on-fly-using-system-codedom-compi – JaggenSWE May 19 '16 at 11:49
  • You know there's this thing called Google, which fill find plenty of results for you when searching for a term. – Visual Vincent May 19 '16 at 15:06
  • https://github.com/ElektroStudios/ElektroKit/blob/668ea10b80e6c4601332223754a6ca69a823e7b6/Solution/v1.5/Elektro.Interop/Types/VisualBasicCompiler.vb A full example is commented in the source-code. – ElektroStudios May 19 '16 at 21:03
  • Sorry I should have said this at the start, I don't want to use a string builder and vs already has a complier built in. But thanks for the help regardless. – Joshua Thomas May 20 '16 at 08:18

1 Answers1

0
  1. Open the text file in notepad
  2. Create a new solution or open a .vb file in Visual Studio
  3. If you create a new forms solution, press F7 to switch to code view
  4. Copy and paste the code from Notepad into the code editor
  5. Run it and the code is auto-saved.

Why don't you let us see your code?

Happypig375
  • 1,022
  • 1
  • 12
  • 32