Executing a string as a VB cmd during runtime 
Author Message
 Executing a string as a VB cmd during runtime

How does one execute a VB command from a string during runtime. I believe it
has to do with the ExecWait command, but I'm not sure.  Thank you for your
help.

Steve



Sat, 14 May 2005 12:40:34 GMT  
 Executing a string as a VB cmd during runtime
Hi Steve,

Depends on what you mean by command.  You may be able to use reflection,
CallByName, or scripting host, or il emit.  Just depends on what it is you are
trying to do.


Quote:
> How does one execute a VB command from a string during runtime. I believe it
> has to do with the ExecWait command, but I'm not sure.  Thank you for your
> help.

> Steve



Sat, 14 May 2005 13:24:11 GMT  
 Executing a string as a VB cmd during runtime
Hi Bill,

I'm trying to get a control array assigned to 9 consecutive radio buttons. I
would like to put it in a for next loop. The code would do the following:

Dim rdbColor(9) As RadioButton

rdbColor(1) = RadioButton1
rdbColor(2) = RadioButton2
rdbColor(3) = RadioButton3
...
rdbColor(9) = RadioButton9

Thank you for your help.

Steve L.


Quote:
> Hi Steve,

> Depends on what you mean by command.  You may be able to use reflection,
> CallByName, or scripting host, or il emit.  Just depends on what it is you
are
> trying to do.



> > How does one execute a VB command from a string during runtime. I
believe it
> > has to do with the ExecWait command, but I'm not sure.  Thank you for
your
> > help.

> > Steve



Sun, 15 May 2005 02:49:16 GMT  
 Executing a string as a VB cmd during runtime
Hi Steve,

Yeh, there's probably a few ways you can do this. The first that comes to mind is
reflection, eg :Type.InvokeMember
But it isn't as simple as that <g> The issues are whether these things are defined
at design time WithEvents or not.  The reason is, that VB.NET, creates a property
get/set for each control if they are declared as WithEvents, so:

Friend WithEvents foo As Bar
becomes

Private _foo as Bar

Friend Property foo() as Bar
    Get
        ....
    End Get
    Set
        ...
    End Set
End Property

The reason this is important to know is because if you are after the field, it now
has an "_" at the start of the name and the field is always private. Alternatively
you can invoke the property Get. The following code works on the hidden private
fields:

Dim rdbColor(9) As RadioButton
Dim i as Int32

For i = 1 to 9 ' what happened to item (0) ???
    rdbColor(i) = CType(Me.GetType.InvokeMember("_RadioButton" & i, _
                            Reflection.BindingFlags.GetField Or _
                            Reflection.BindingFlags.NonPublic Or  _
                            Reflection.BindingFlags.Instance, _
                            Nothing, Me, Nothing), _
                       RadioButton)
Next


Quote:
> Hi Bill,

> I'm trying to get a control array assigned to 9 consecutive radio buttons. I
> would like to put it in a for next loop. The code would do the following:

> Dim rdbColor(9) As RadioButton

> rdbColor(1) = RadioButton1
> rdbColor(2) = RadioButton2
> rdbColor(3) = RadioButton3
> ...
> rdbColor(9) = RadioButton9

> Thank you for your help.

> Steve L.



> > Hi Steve,

> > Depends on what you mean by command.  You may be able to use reflection,
> > CallByName, or scripting host, or il emit.  Just depends on what it is you
> are
> > trying to do.



> > > How does one execute a VB command from a string during runtime. I
> believe it
> > > has to do with the ExecWait command, but I'm not sure.  Thank you for
> your
> > > help.

> > > Steve



Sun, 15 May 2005 15:27:15 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. set rs = cmd.Execute fails when cmd.CommandText includes spaces

2. Executing VB command strings at runtime

3. Executing a function during runtime

4. Executing a function() during runtime

5. ADO: cmd.Execute vs cn.Execute

6. _ conn.execute or cmd.execute?

7. _ conn.execute or cmd.execute?

8. VBA Word, data stored in strings during runtime, and after closing

9. Dim a string to a fixed size during runtime

10. How to set CR8 connection string during runtime in VB6

11. Is it possible to get filename of .CMD filename that is being executed by CMD.EXE _FROM_ inside the .CMD script?

12. Detecting cmd button click during loop

 

 
Powered by phpBB® Forum Software