CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Jul 2003
    Location
    Chennai
    Posts
    42

    Execute Statement ????

    Hello,

    In VB we have this Statement running

    Dim lvFrm as Form

    Set lvFrm = FrmTest
    msgbox lvFrm.Caption

    if the Statement "Set lvFrm = FrmTest" is a STRING then how could we execute ? Using Script Control.

    My aim is to Load a form using a String Statement.

    I tried ScriptControl.ExecuteStatement "Load FrmTest"

    An Error Popups " Typemismatch: 'Load' "

    Any Solution.......

    Thank you
    Regards
    Soundar
    your's
    Soundar

  2. #2
    Join Date
    Dec 2001
    Posts
    6,332
    I'm not sure if it is exactly what you are looking for, but check into the CallByName() function.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  3. #3
    Join Date
    Jul 2003
    Location
    Chennai
    Posts
    42

    Execute Statement

    hi.

    I want to execute a String Statement "Load FrmTest" .. to Load a Form .

    (FrmTest -> is a Form)

    How do I call this Using Script Control..

    Regards
    Soundar
    your's
    Soundar

  4. #4
    Join Date
    Jul 2001
    Location
    Salzburg, Austria
    Posts
    126
    Take a look

    http://www.codeguru.com/forum/showth...hreadid=205597

    is in the sticky item: VB frequently asked questions.
    I hope is what you need.

    Jaime

  5. #5
    Join Date
    Jul 2003
    Location
    Chennai
    Posts
    42

    Error Occurs

    Hi,

    Here the FormName is in String : its shows


    Object Required : XYZ (FormName)

    Or else how to Convert the String to Object ??

    Soundar
    your's
    Soundar

  6. #6
    Join Date
    Sep 2003
    Location
    Lahore, Pakistan
    Posts
    6
    Hi Dear
    Please try this.

    Set the Project Reference to Microsoft Script Control 1.0 from Project ->References

    General Declaration Section
    ---------------------------------
    Option Explicit
    Dim scpt As ScriptControl
    Dim frmMain


    Form Load Event
    ----------------------

    Set scpt = New ScriptControl

    With scpt
    .Language = "VBScript"
    .AddObject "frmMain", Form2
    End With


    Command Button Click Event
    ------------------------------------

    scpt.ExecuteStatement " MsgBox frmMain.Caption"

  7. #7
    Join Date
    Jul 2003
    Location
    Chennai
    Posts
    42

    Still......

    Hi... samitanveer


    In your Code.. Form2 is an Object...

    Consider if that is being a String ????

    Reply me... I am Awaiting.....


    Soundar
    your's
    Soundar

  8. #8
    Join Date
    Jan 2003
    Location
    7,107 Islands
    Posts
    2,487
    Hi bsoundar,

    Another way to load the form is by adding it into VB.Forms collection, this is much simplier.

    Code:
    VB.Forms.Add "Form2"
    Have a nice day
    Busy

  9. #9
    Join Date
    Jul 2003
    Location
    Chennai
    Posts
    42

    Thumbs up Thank You & to All

    IT WORKS ! IT WORKS !! AND IT WORKS !!!!


    Thanks A lot ....... " Thread1 "



    and to all the members who atleast tried to give solutions...


    Regards
    Soundar
    your's
    Soundar

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured