473,513 Members | 2,391 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

executing vbscript functions from a C# winform app

Hi Group.

I have an old VB6 application which loads a number of gui controls
from an inifile and for each control the inifile states the name of
the vbscript that should be executed once the control is clicked or
otherwise triggered.
My question is whether it is possible to execute the vb scripts from
C#? There are multiple scripts in the same file.

If that is not possible I sure would like a hint about how I create a
winforms app where the eventhandler is defined at runtime, not
compiletime.

TIA

Kasper
Feb 10 '08 #1
3 2091
Well, the simplest way is to store something useful in the tag, and
simply have a shared handler, i.e.

private void foo_Clicked(object sender, EventArgs args) {
Control cont = sender as Control;
if(cont!= null) {
// do something with cont.Tag
}
}

Then when looping:

foreach(whatever) {
SomeControl foo = new SomeControl();
// init
foo.Tag = {something useful}; // could also use Name I suppose
foo.Clicked += foo_Clicked;
}

Depending on needs, you can do things a lot more sophisticated.

Marc
Feb 10 '08 #2
(you'll also need to add each "foo" onto the form somewhere ;-p)

Marc
Feb 10 '08 #3
Kasper,

I think that the best option here is to refactor the VB6 app so that the
UI is contained in hostable ActiveX controls and then host those controls in
your C# app, and let the VB6 code that is being interoped with handle the
script (as you were before).

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Kasper" <ka************@gmail.comwrote in message
news:eb**********************************@q77g2000 hsh.googlegroups.com...
Hi Group.

I have an old VB6 application which loads a number of gui controls
from an inifile and for each control the inifile states the name of
the vbscript that should be executed once the control is clicked or
otherwise triggered.
My question is whether it is possible to execute the vb scripts from
C#? There are multiple scripts in the same file.

If that is not possible I sure would like a hint about how I create a
winforms app where the eventhandler is defined at runtime, not
compiletime.

TIA

Kasper
Feb 11 '08 #4

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

Similar topics

1
4991
by: Valentina Boycheva | last post by:
Thanks for the reply. I already have "Learning Python" from Mark Lutz and David Ascher, which covers 2.3 (I am in 2.4). However, it seems like heavy artillery to me. What I want is, for instance,...
29
5989
by: Christopher Brandsdal | last post by:
If I have a .ASP page that runs JScript code - is it possible to include an ..ASP page that runs VBscript???
16
9313
by: Mike Schinkel | last post by:
Does anyone know if there are bugs in VBScript's GetRef()? I'm using VBScript Version 5.6.8515 on Win2003Server w/ASP. Sometimes it returns an object that VarType() says is a vbObject. Other...
4
12657
by: chris.dunigan | last post by:
I'm looking for an example of how to execute an existing DTS­ package from an ASP (VB)script and would appreciate any and all response. ­I don't even know if it's possible Thanks - Chuck...
3
2012
by: Mark Fox | last post by:
Hello, I am porting some old ASP 3.0 VBScript code to C#.NET and am not sure what the equivalent C# functions are for a couple VBScript functions. So my first question is: 1) Is there...
59
5800
by: Mr. x | last post by:
Hello, I need a good help/tutorial for VB, please (I preffer *.chm help file). Also : for the function : now() in VBScript for getting the current time, what is the counterpart function of VB ?...
1
3430
by: Andrew Wan | last post by:
How can VBScript code access JScript code variables in the same ASP page? <SCRIPT LANGAUGE="VBScript"> Dim a a = 10 </SCRIPT> <SCRIPT LANGUAGE="JScript"> Response.Write(a); </SCRIPT>
2
4166
by: boole | last post by:
Hi there, when my ASP page receives the client request, I want to gather the request data (form), promptly end the response to the client (successful) and continue doing what I need to do with the...
2
7461
by: Carlton Kirby | last post by:
I need to execute a job on a SQL Express 2005 instance (no SQLAgent). The job will be executed manually by a user, so it doesn't need to be scheduled to run automatically. I thought I could...
0
7265
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
7171
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7388
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7111
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7539
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5095
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
3240
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3228
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
461
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.