473,385 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

VB2005 execute string

Hi all,

I would like to execute/evaluate a string that contains a VB script,
for example:
Dim s as string = "Dim avar as integer = 1"
' Evaluate s...
so s can be executed during runtime and avar will be created as a
result.

Thanks.
Jerzy
je*************@gmail.com

Jul 23 '07 #1
3 1508
Reflection gives you the ability to emit code and run it. There is no direct
equivalent of the java (or JavaScript) eval function, but you can wrap the
attempt in an exception handler.

There is probably another way to play this game.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)

************************************************
Think outside the box!
************************************************
"Jerzy Zielinski" <je*************@gmail.comwrote in message
news:11**********************@q75g2000hsh.googlegr oups.com...
Hi all,

I would like to execute/evaluate a string that contains a VB script,
for example:
Dim s as string = "Dim avar as integer = 1"
' Evaluate s...
so s can be executed during runtime and avar will be created as a
result.

Thanks.
Jerzy
je*************@gmail.com

Jul 23 '07 #2
Thank you for this sugestion.

OK. If there is no "eval", like in java. Maybe there is a way to
iterate the variable names to generate them automaticly with different
prefixes or suffixes. Something like: var1, var2, var3, ... varn. or
to pass a prefix in a function, procedure, sub call prefix & canstant
name would give a name of a boxes or lables in a page; like st_box,
nd_box, rd_box so in function call there is function_name("st"), and
in function there is variable&"_box".Text = "some text"
Thank you in advance
Jerzy

On Jul 23, 4:26 pm, "Cowboy \(Gregory A. Beamer\)"
<NoSpamMgbwo...@comcast.netNoSpamMwrote:
Reflection gives you the ability to emit code and run it. There is no direct
equivalent of the java (or JavaScript) eval function, but you can wrap the
attempt in an exception handler.

There is probably another way to play this game.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBAhttp://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)

************************************************
Think outside the box!
************************************************"J erzy Zielinski" <jerzy.zielin...@gmail.comwrote in message

news:11**********************@q75g2000hsh.googlegr oups.com...
Hi all,
I would like to execute/evaluate a string that contains a VB script,
for example:
Dim s as string = "Dim avar as integer = 1"
' Evaluate s...
so s can be executed during runtime and avar will be created as a
result.
Thanks.
Jerzy
jerzy.zielin...@gmail.com- Hide quoted text -

- Show quoted text -

Jul 24 '07 #3
If you want to dynamically put out controls, that is simple. Just set a
container control, like a panel, and add controls to it. You can get far
more complex if you use data bound controls, like a GridView, etc., and add
code to the row databinding event. This allows you to alter the output to
fit your shims. If you then want to grab values, you can iterate through the
controls collection when the page is posted back.

Am I getting close?

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)

************************************************
Think outside the box!
************************************************
"Jerzy Zielinski" <je*************@gmail.comwrote in message
news:11*********************@m3g2000hsh.googlegrou ps.com...
Thank you for this sugestion.

OK. If there is no "eval", like in java. Maybe there is a way to
iterate the variable names to generate them automaticly with different
prefixes or suffixes. Something like: var1, var2, var3, ... varn. or
to pass a prefix in a function, procedure, sub call prefix & canstant
name would give a name of a boxes or lables in a page; like st_box,
nd_box, rd_box so in function call there is function_name("st"), and
in function there is variable&"_box".Text = "some text"
Thank you in advance
Jerzy

On Jul 23, 4:26 pm, "Cowboy \(Gregory A. Beamer\)"
<NoSpamMgbwo...@comcast.netNoSpamMwrote:
>Reflection gives you the ability to emit code and run it. There is no
direct
equivalent of the java (or JavaScript) eval function, but you can wrap
the
attempt in an exception handler.

There is probably another way to play this game.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBAhttp://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)

*********************************************** *
Think outside the box!
************************************************" Jerzy Zielinski"
<jerzy.zielin...@gmail.comwrote in message

news:11**********************@q75g2000hsh.googleg roups.com...
Hi all,
I would like to execute/evaluate a string that contains a VB script,
for example:
Dim s as string = "Dim avar as integer = 1"
' Evaluate s...
so s can be executed during runtime and avar will be created as a
result.
Thanks.
Jerzy
jerzy.zielin...@gmail.com- Hide quoted text -

- Show quoted text -


Jul 24 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jedi10180 | last post by:
Does ShellExecute work in VB2005? I am trying to open a pdf with a button - I get no errors, but nothing is happening. Here is my code: Option Explicit On Public Class frmPROTest Const...
0
by: Cyril Gupta | last post by:
Something weird is going on... I have installed the Visual Basic 2005 along with the .Net framework 2.0 but somehow the features that I should have got along with ADO.Net 2 are all missing. I don't...
10
by: Charles Hunt | last post by:
Hi, When running this code in VB2003 Sub guidtest() Dim gstring As String Dim gid As Guid
2
by: Jordi Julią | last post by:
Hello, I need to create with VB2005 an instance of one of the classes of the project in run time. For example: - The Namespace root and the name of the project are he himself: "Project" -...
15
by: Galen Somerville | last post by:
I have an app using a VB6 ActiveX.dll which I also have made as an exe. Both the dll and exe have exactly the same code and start in Sub Main. There is no form involved. I start this activex as...
92
by: =?Utf-8?B?bW9iaWxlbW9iaWxl?= | last post by:
I'm trying to load this structure for a call to DeviceIoControl: typedef struct _NDISUIO_QUERY_OID { NDIS_OID Oid; PTCHAR ptcDeviceName; UCHAR Data; } NDISUIO_QUERY_OID, *PNDISUIO_QUERY_OID; ...
0
by: =?Utf-8?B?SmFtZXNB?= | last post by:
I am trying to use the code shown in the VB2005 Help on how "To receive strings from the serial port". The code was cut and pasted and it gives no errors when "debugged" in VB2005, but it simply...
10
by: zubair1 | last post by:
Hi, I pretty new to VB2005 i was just working on a project a problem arise which really got me frustrated. Dim searchThese(1) As String myvar(0) = "Hi" myvar(1) =...
3
by: John Dann | last post by:
We've got a VB2005 program written some time back that we're trying to do some maintenance on still from within VB2005 but now running on a Vista Business PC (which I think may be relevant to the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.