Sometimes I may need to use VB's IDE, and don't need to establish a VB project and perform a VB code separately. For example, calculate an expression in my program, preview a function of a VB inside, and the user wants to execute It is not sure, so it is difficult to control the program, so we can directly call the vbide interpretation function, if the user enters, as long as it is effective, it can be running normally, but the above is just my idea, the technology is this, but specifically use It's the intention of using the user.
In fact, it is very simple, just call an API
Private declare function ebexecuteline lib "vba6.dll" (byval pstringtoexec as long, Byval unknownn1 as long, byval fcheckonly as long) AS long condition is already sufficient, let's see how we used it.
Public Function ExecuteLine (Scode As String, Optional Fcheckonly As Boolean) AS Boolean ExecuteLine = EbexecuteLine (Strptr (Scode), 0 &, 0 &, Abs (FcheckOnly) = 0nd Function
Call this time when used,
Private sub fascist1_click () Dim Res boilean res = executeLine (text1.text) end sub
Enter an example in Text1, such as: msgbox "^ _ ^, this is a VB statement", "OK"
Execute how it looks, it is very convenient.
There is no highly technical here, although it is a few APIs, but sometimes it is not small!
^ _ ^