.Net Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - More.Net Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 24th, 2012, 01:17 AM
NeoScyther NeoScyther is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 12 NeoScyther User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 32 m 26 sec
Reputation Power: 0
VB.NET 2008: Importing Code From a Text File

Hey everyone,

I know I'm probably up the creek without a paddle here, but is it at all possible in VB.NET 2008 to import code from a text file? I know it doesn't sound practical, but for a project I'm experimenting with, the code that gets executed all depends on particular options being chosen, and there will be a lot of options to choose from, and the code won't be the same for each.

If worse comes to worse, I have a couple backup plans to try, but I was just wondering if it's at all possible to write some code in a text file (or other file type if need be), then import that into VB.NET, similar to how it's done when working with HTML and Javascript. I know I'm looking at a long shot here.

UPDATE: Never mind, I'm pretty sure now this can't be done, at least not easily.

Reply With Quote
  #2  
Old April 28th, 2012, 10:46 AM
f'lar's Avatar
f'lar f'lar is offline
ASP.Net MVP
Dev Shed Specialist (4000 - 4499 posts)
 
Join Date: Aug 2003
Location: WI
Posts: 4,378 f'lar User rank is General 8th Grade (Above 100000 Reputation Level)f'lar User rank is General 8th Grade (Above 100000 Reputation Level)f'lar User rank is General 8th Grade (Above 100000 Reputation Level)f'lar User rank is General 8th Grade (Above 100000 Reputation Level)f'lar User rank is General 8th Grade (Above 100000 Reputation Level)f'lar User rank is General 8th Grade (Above 100000 Reputation Level)f'lar User rank is General 8th Grade (Above 100000 Reputation Level)f'lar User rank is General 8th Grade (Above 100000 Reputation Level)f'lar User rank is General 8th Grade (Above 100000 Reputation Level)f'lar User rank is General 8th Grade (Above 100000 Reputation Level)f'lar User rank is General 8th Grade (Above 100000 Reputation Level)f'lar User rank is General 8th Grade (Above 100000 Reputation Level)f'lar User rank is General 8th Grade (Above 100000 Reputation Level)f'lar User rank is General 8th Grade (Above 100000 Reputation Level)f'lar User rank is General 8th Grade (Above 100000 Reputation Level)f'lar User rank is General 8th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 2 Days 11 h 4 m 57 sec
Reputation Power: 1509
Send a message via Google Talk to f'lar
It's possible, but not recommended. What you're asking about is an Eval() function, and those are not a good idea for general purpose languages like VB. It's really intended for for sandboxed languages like javascript. In dynamic languages like Ruby or Python, if you use Eval() it's probably a security hole.

.Net offers two alternatives:

One is to load a class library (dll) at runtime using Assembly.LoadFile()
The other is to use a domain specific language.

Both allow you to load arbitrary code at runtime in safer context.
__________________
Primary Forum: .Net Development
Holy cow, I'm now an ASP.Net MVP!

[Moving to ASP.Net] | [.Net Dos and Don't for VB6 Programmers]

http://twitter.com/jcoehoorn

Reply With Quote
  #3  
Old May 17th, 2012, 02:51 AM
aa.web.dev aa.web.dev is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2012
Posts: 9 aa.web.dev User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 18 m 51 sec
Reputation Power: 0
Smile

Hello NeoScyther,

Its possible but not recommended.Actually the main thing is SREAMREADER AND STREAMWRITER which basically helps you to read and write the file.

then,

Imports System.IO
Dim FileReader As StreamReader

then put

Dim results As DialogResult

results = OpenFileDialog1.ShowDialog

If results = DialogResult.OK Then

'Code to be executed if OK button was clicked

Else

'Code to be executed if Cancel button was clicked

End If

End Sub



I think it will help you

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - More.Net Development > VB.NET 2008: Importing Code From a Text File

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap