|
-
Oct 30th, 2002, 03:36 PM
#1
Thread Starter
Addicted Member
Executing Vb code from a Vb program [SOLOVED]
Um i want to execute a VB code from a vb program... I think it works... Like i want to write in a textbox "Msgbox "Hello"" and i want a msgbox to popup.. heelp
Last edited by Jonte1989; Oct 30th, 2002 at 04:12 PM.
/Jonte
-
Oct 30th, 2002, 04:02 PM
#2
Banned
You can use the MS Scripting control, but it is a bit limited....
-
Oct 30th, 2002, 04:06 PM
#3
Thread Starter
Addicted Member
-
Oct 30th, 2002, 04:12 PM
#4
Thread Starter
Addicted Member
Hehe that's easy! thanx for the tip!
-
Oct 30th, 2002, 04:14 PM
#5
Addicted Member
I have posted this one before, but it may be something you can work with.
Code:
'Module Level
Option Explicit
Private Declare Function EbExecuteLine Lib "vba6.dll" (ByVal pStringToExec As Long, ByVal Unknownn1 As Long, ByVal Unknownn2 As Long, ByVal fCheckOnly As Long) As Long
Public Sub Main()
Form1.Show
End Sub
Public Function ExecuteLine(sCode As String, Optional fCheckOnly As Boolean) As Boolean
ExecuteLine = EbExecuteLine(StrPtr(sCode), 0&, 0&, Abs(fCheckOnly)) = 0
End Function
'Form Level
Private Sub cmdExecute_Click()
Call ExecuteLine(txtCode.Text, False)
End Sub
.·*¨) ¸.·*¨) ¸.·*¨*
(¸.*´ ¸.·´*'~*Renee~* (¸.*´~*
Funny how the little things can stop you dead in your tracks. 
-
Oct 30th, 2002, 04:37 PM
#6
Thread Starter
Addicted Member
Is this code working as it is or do i have to edit it some way? I can not get it to wark... Well its late.. good night and thanx in advance.
-
Oct 30th, 2002, 04:41 PM
#7
Addicted Member
It works the way it is for very simple tasks. Add a module to your project paste in the module code. Place a textbox and a command button on you form behind the command paste in the code. Run the program in the textbox type in msgbox"HELLO"
press the command button. I am sure with some work it could do more.
.·*¨) ¸.·*¨) ¸.·*¨*
(¸.*´ ¸.·´*'~*Renee~* (¸.*´~*
Funny how the little things can stop you dead in your tracks. 
-
Oct 30th, 2002, 04:46 PM
#8
Hyperactive Member
It doesn't work compiled, I think the declare statement is bad because it can't find the DLL when compiled. Otherwise that is VERY cool. Better than callbyname...
Last edited by Knowledge_is_Et; Oct 30th, 2002 at 04:55 PM.
Now returning to the world of VB. Please make sure your seatbelts are securely fastened and all trays are in their upright and locked position.
-
Oct 30th, 2002, 04:57 PM
#9
Hyperactive Member
Ok, i've also noticed you must call things from the lowest level:
eg: instead of label1.caption = "hi"
you use form1.label1.caption = "hi"
just a note, jonte might want to know???
Amazing that you found this inside the VB dll, what other functions hide in there?
Now returning to the world of VB. Please make sure your seatbelts are securely fastened and all trays are in their upright and locked position.
-
Oct 30th, 2002, 05:27 PM
#10
Addicted Member
Actually I found the code somewhere on the net. I haven't really done much with it, it has just been a play toy. Like you said you must call things from the lowest level. You have to type in the code simalar to using the debug window. For example, For i = 1 to 10: msgbox "The value of i is = " & i & ".": next i. It is cool, but not alot of use for me. I guess if I was one of these coding experts I could do more with it.
.·*¨) ¸.·*¨) ¸.·*¨*
(¸.*´ ¸.·´*'~*Renee~* (¸.*´~*
Funny how the little things can stop you dead in your tracks. 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|