从textfile中读取代码并在VB中执行 [英] Read code from textfile and execute in VB

查看:96
本文介绍了从textfile中读取代码并在VB中执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个应用程序,当你按下按钮时,它会读取文本文件,并执行其中的代码。



我正在阅读文本文件通过streamreader(readtoend),现在我想执行从文本文件中读取的代码...



我已经有了我的资源,如果需要我可以使用它(下面)



谢谢。



资源外观示例:



I am trying to make an app that when you press a button, it reads a textfile, and executes the code inside it.

I am reading the textfile via streamreader (readtoend) , now i would like to execute the code read from the text file...

I already have my Resources which I could use if needed (below)

thank you.

Sample of how the resources look:

Imports System.Net
Imports System.Text.Encoding
Imports System.Net.Sockets
Imports System
Imports System.IO.Ports
Imports System.IO
Imports System.Threading
Imports System.ComponentModel
Imports WindowsApplication1
Imports System.CodeDom
Imports System.CodeDom.Compiler
Imports Microsoft.Win32
Imports Microsoft.CSharp
Imports Microsoft.VisualBasic
Imports System.IO.File
Imports System.Windows.Forms

Public Class testfromfile

        %111%

End Class





我尝试过:



INITIAL APPROACH:我正在考虑使用streamreader的信息从资源中替换值%111%然后执行代码....



任何想法如何 去做这个?试过CodeDom但是无法使它工作。



What I have tried:

INITIAL APPROACH: I was thinking of replacing the values %111% from the resources with the info of the streamreader and then executing the code....

any ideas how to do this? tried CodeDom but was not able to make it work.

推荐答案

检查一下:如何使用Visual Basic .NET或Visual Basic 2005编译器以编程方式编译代码 [ ^ ]


这篇关于从textfile中读取代码并在VB中执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆