473,326 Members | 2,111 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,326 software developers and data experts.

Execute a String

Hi!

Is there a way to execute a string?
That means:
1. My app shows dialog box where I write "StartCounting"
2. My program run StartCounting sub
Is there any other way then just using "case"?
Nov 20 '05 #1
13 2196
Is StartCounting a method in a class of yours?

if so: something like...

imports System.Reflection
....
dim myType = myObject.GetType()
dim myMethod as MethodInfo = myType.GetMethod("StartCounting")
dim result as Object = myMethod.Invoke(myObject, new Object(){
....parameters...} or Nothing)

"zurg" <zu*****@wp.pl> wrote in message
news:Ol**************@TK2MSFTNGP11.phx.gbl...
Hi!

Is there a way to execute a string?
That means:
1. My app shows dialog box where I write "StartCounting"
2. My program run StartCounting sub
Is there any other way then just using "case"?

Nov 20 '05 #2

Take a look at this
http://www.dotnet247.com/247referenc.../18/90485.aspx


"zurg" <zu*****@wp.pl> schrieb im Newsbeitrag
news:Ol**************@TK2MSFTNGP11.phx.gbl...
Hi!

Is there a way to execute a string?
That means:
1. My app shows dialog box where I write "StartCounting"
2. My program run StartCounting sub
Is there any other way then just using "case"?

Nov 20 '05 #3
* "zurg" <zu*****@wp.pl> scripsit:
Is there a way to execute a string?
That means:
1. My app shows dialog box where I write "StartCounting"
2. My program run StartCounting sub
Is there any other way then just using "case"?


Samples:

<http://www.codeproject.com/useritems/evaluator.asp>
<http://www.codeproject.com/csharp/livecodedotnet.asp>

If you have a DevX account:

<http://www.devx.com/codemag/Article/10352/0/page/1>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
Both of you gave me a helpful answear - thank you!

But I'd like it also to work like this:

Module Module1
Sub Main
Dim strCommand As String

strCommand = "Hello"
Run(strCommand)'or sth like this
End Sub

Sub Hello
Msgbox("Hello")
End Sub
End Module
and it should show "Hello" messagebox...
How to do so?
Nov 20 '05 #5
Instead of Run use:

Microsoft.VisualBasic.Interaction.CallByName(me,st rCommand ,CallType.Method)

"zurg" <zu*****@wp.pl> schrieb im Newsbeitrag
news:O6**************@TK2MSFTNGP10.phx.gbl...
Both of you gave me a helpful answear - thank you!

But I'd like it also to work like this:

Module Module1
Sub Main
Dim strCommand As String

strCommand = "Hello"
Run(strCommand)'or sth like this
End Sub

Sub Hello
Msgbox("Hello")
End Sub
End Module
and it should show "Hello" messagebox...
How to do so?

Nov 20 '05 #6
I get an error:

'Me' is not valid within a Module

this method is perfect to any objects, but what about modules?
Nov 20 '05 #7
"zurg" <zu*****@wp.pl> schrieb
Both of you gave me a helpful answear - thank you!

But I'd like it also to work like this:

Module Module1
Sub Main
Dim strCommand As String

strCommand = "Hello"
Run(strCommand)'or sth like this
End Sub

Sub Hello
Msgbox("Hello")
End Sub
End Module
and it should show "Hello" messagebox...
How to do so?


Where do you get the strings from? Which programming language is used for
these commands? Writing commands is actually a programmer's job. Commands
are parts of projects, and projects are compiled using the compiler, then
executed.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #8

Never used Moduls...... It's very old fashioned to use Moduls.....

Simply create a Class an call it from your Modul if you have a
Console-Application.
The put every thing ito the Class instead of the Moduls Shit.

Like this

Module Module1
Sub Main
dim xy as new MyClass
xy.run("bla")
End Sub
End Module

Class MyClass

Sub Run(bla)

End sub
Sub Hello
Msgbox("Hello")
End Sub

End Class

"zurg" <zu*****@wp.pl> schrieb im Newsbeitrag
news:e0**************@TK2MSFTNGP09.phx.gbl...
I get an error:

'Me' is not valid within a Module

this method is perfect to any objects, but what about modules?

Nov 20 '05 #9
That's of course true...

but I'd like to write quite huge application that can be completly
configurated by the config file.
When I say "completly" I mean that I want as well change some information
inside the app as which funcion should be run...
Unluckly I'm still learning the construcion of the configuration file and I
only now how to read from there only strings...
that's why I'm looking for a way to treat a string like a command to run and
the "case" construction isn't the best for me...
Mayby there's another way to do so using the configuration file... I'm still
working on it...

Hope I made myself clear...
Uzytkownik "Armin Zingler" <az*******@freenet.de> napisal w wiadomosci
news:OL**************@TK2MSFTNGP09.phx.gbl...
"zurg" <zu*****@wp.pl> schrieb
Both of you gave me a helpful answear - thank you!

But I'd like it also to work like this:

Module Module1
Sub Main
Dim strCommand As String

strCommand = "Hello"
Run(strCommand)'or sth like this
End Sub

Sub Hello
Msgbox("Hello")
End Sub
End Module
and it should show "Hello" messagebox...
How to do so?


Where do you get the strings from? Which programming language is used for
these commands? Writing commands is actually a programmer's job. Commands
are parts of projects, and projects are compiled using the compiler, then
executed.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #10
try this
public module modTest
public sub start()
dim t as Type = GetType(modTest)
dim mi as MethodInfo = t.GetMethod("stringStuff")
mi.Invoke(nothing, nothing)
end sub

public sub stringStuff()
...
end sub

end module
"zurg" <zu*****@wp.pl> wrote in message
news:e0**************@TK2MSFTNGP09.phx.gbl...
I get an error:

'Me' is not valid within a Module

this method is perfect to any objects, but what about modules?

Nov 20 '05 #11
Works perfect!!!!
That's the thing I was looking for...

Thank you
Nov 20 '05 #12
KS
The other method did work too !

KS, Denmark

"zurg" <zu*****@wp.pl> skrev i en meddelelse
news:uB**************@TK2MSFTNGP09.phx.gbl...
Works perfect!!!!
That's the thing I was looking for...

Thank you

Nov 20 '05 #13
"zurg" <zu*****@wp.pl> schrieb
That's of course true...

but I'd like to write quite huge application that can be completly
configurated by the config file.
When I say "completly" I mean that I want as well change some
information inside the app as which funcion should be run...
Unluckly I'm still learning the construcion of the configuration file
and I only now how to read from there only strings...
that's why I'm looking for a way to treat a string like a command to
run and the "case" construction isn't the best for me...
Mayby there's another way to do so using the configuration file...
I'm still working on it...

Hope I made myself clear...


Yep. Depending on your application's structure, you own interpreter - the
simplest would be a Select Case - might be a solution.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #14

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

Similar topics

0
by: Eric Wood | last post by:
We have an application that is accessed using shared drives, client executes program from server. We have already coded the program to create and save the a bat file either locally on the users...
7
by: William Gill | last post by:
I have been trying to pass parameters as indicated in the api. when I use: sql= 'select * from %s where cusid = %s ' % name,recID) Cursor.execute(sql) it works fine, but when I try : sql=...
6
by: Doohan W. | last post by:
Hi, I'm now working with DB2, and I can't find out how to execute the contents of a string Statement, without using a Java/... procedure, only using SQL statements. I know that some SQBDs such...
3
by: Lyle Fairfield | last post by:
MS-SQL Server utilities Enterprise Manager and Query Analyzer will model almost any MS-SQL object as a simple script file with a default ".sql" extension. But how to "run these files? They are...
4
by: Chris | last post by:
I posted this in the C# language group, then thought it might be more appropriate in this group. I would not cross-post except I want the answer so badly. I built small C# Web and Web Service...
2
by: nick | last post by:
Hi, I wondering if it is possible in asp.net to somehow execute a string of code as if it were a page on the server. That is to say, if I executed the following code which resided in an aspx...
2
by: Dune | last post by:
I'm trying to execute an aspx page by calling Server.Execute. The aspx page I'm trying to execute is in a different web app from the aspx page containing the Server.Execute statement. A slightly...
3
by: Peter Afonin | last post by:
Hello, Our SQL server used to run under System account, and I had no problems executing DTS packages from the ASP.NET: Dim oPkg As DTS.Package oPkg = CreateObject("DTS.Package")...
1
by: Eric Wood | last post by:
We have an application that is accessed using shared drives, client executes program from server. We have already coded the program to create and save the a bat file either locally on the users...
3
by: Jeeran | last post by:
I need to perform url rewriting to convert this (for example): /blogs/feeds/popular/posts/ to this: /blogs/feeds.aspx?type=popular&type2=posts What I did was the following: 1. Created an...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.