[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 174
  • Last Modified:

Dynamically create a procedure or function

Anyone know how to do this?  I want to create a procedure at startup.

Let's say...

Private Sub HelloWorld()
Dim sMsg as string
sMsg = "Hello World"
MsgBox sMsg
End Sub
0
born4code
Asked:
born4code
  • 2
1 Solution
 
Shiju SasidharanCommented:
0
 
Shiju SasidharanCommented:
hi try this
'Goto Project Menu ->References
'add reference Microsoft Script Control 1.0
'------------------------------------------
Private Sub Command1_Click()
    Dim sc As New ScriptControl
    sc.Language = "VbScript"
    sc.AddCode _
        "Function HelloWorld()" & vbCrLf & _
        "    Dim sMsg" & vbCrLf & _
        "    sMsg = ""Hello World""" & vbCrLf & _
        "    MsgBox sMsg" & vbCrLf & _
        "End Function"
    sc.Eval "HelloWorld()"
End Sub
'------------------------------------------

;-)
Shiju

0
 
born4codeAuthor Commented:
Thank you. Works great.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now