Execute VB code from a string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • grantculverwell
    New Member
    • Jan 2007
    • 1

    Execute VB code from a string

    Hi

    Does anyone know how to take a string (eg. read from a database field) and execute that string as vb code.
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Originally posted by grantculverwell
    Does anyone know how to take a string (eg. read from a database field) and execute that string as vb code.
    I'll be quote surprised if you can do that. But I could be wrong, of course.

    By the way, what version of VB are you talking about?

    Comment

    • sashi
      Recognized Expert Top Contributor
      • Jun 2006
      • 1749

      #3
      Originally posted by grantculverwell
      Hi

      Does anyone know how to take a string (eg. read from a database field) and execute that string as vb code.
      Hi there,

      Correct me if i happen to be wrong, are you talking about including the extracted srting into SQL statement? Take care.

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Originally posted by grantculverwell
        Does anyone know how to take a string (eg. read from a database field) and execute that string as vb code.
        I just had another thought about this. It might be possible to generate code (or read it from a database or file) and somehow use the Microsoft Scripting engine to execute it. Perhaps by writing it to a .VBS file and executing that.

        Thoughts, anyone?

        Comment

        • Phaneendra Varma
          New Member
          • Mar 2007
          • 1

          #5
          I understand that you want to do something like this
          "text1.visi ble = False" this is stored in a string and you want to exectue the statement stored in the string. If that is the case may be this link could help.
          Last edited by Killer42; Mar 26 '07, 06:35 AM. Reason: Converted URL to a link.

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            Originally posted by Phaneendra Varma
            I understand that you want to do something like this
            "text1.visi ble = False" this is stored in a string and you want to exectue the statement stored in the string. If that is the case may be this link could help.
            www.thescripts.com/forum/thread15090.html
            Thanks for that link. It does sound to me like just the sort of thing that Grant was looking for. Even if it turns out not to be, I certainly found it interesting. I'll have to look at adding this to the Tips & Tricks thread at the top of the forum.

            Comment

            • higaonon
              New Member
              • Mar 2007
              • 5

              #7
              Originally posted by grantculverwell
              Hi

              Does anyone know how to take a string (eg. read from a database field) and execute that string as vb code.

              If you are talking about embedding it in a SQL statement, that's quite simple...There' s no problem either if it's a pure Visual Basic code, you can a variable of type string then concatenate it with code...Of course don't forget the syntaxes of VB...

              Comment

              Working...