command1_click-VBForums
Results 1 to 14 of 14

Thread: command1_click

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Posts
    198

    command1_click

    Hi;
    I want to run command1_click button which inside form1.form from my mdiform.
    I wrote something like this
    call form1.command1_click
    but it doesn't work.
    thanks

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Candon City, Ilocos Sur, Phils.
    Posts
    10,816

    Re: command1_click

    Have you made command1_click Public?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,915

    Re: command1_click

    You can do it like this:
    VB Code:
    1. Form1.Command1.Value = True
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  4. #4
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Candon City, Ilocos Sur, Phils.
    Posts
    10,816

    Re: command1_click

    Quote Originally Posted by pnish
    You can do it like this:
    VB Code:
    1. Form1.Command1.Value = True
    I have read somewhere that such method is slower...
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  5. #5
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176

    Re: command1_click

    put simply

    VB Code:
    1. 'Change you command1 click event from
    2.  
    3. Private sub Command1_click()
    4.  
    5. 'to
    6.  
    7. Public Sub Command1_click()

    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  6. #6
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: command1_click

    Quote Originally Posted by levent
    Hi;
    I want to run command1_click button which inside form1.form from my mdiform.
    I wrote something like this
    call form1.command1_click
    but it doesn't work.
    thanks
    If you need to execute the code of a control's click event from another form, the easiest and smoothest way to do so is to take the code out of the click event and put it into a Public Sub/Function in a module.

    Now you can easily call it from anywhere.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  7. #7
    Addicted Member JensPeder's Avatar
    Join Date
    Sep 2005
    Posts
    249

    Re: command1_click

    Quote Originally Posted by Hack
    If you need to execute the code of a control's click event from another form, the easiest and smoothest way to do so is to take the code out of the click event and put it into a Public Sub/Function in a module.

    Now you can easily call it from anywhere.
    I absolutely agree with this, especially if you're plan on calling the code alot.





    and cover!

  8. #8
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176

    Re: command1_click

    Just remember to update it when you update the other sub. Thats the only trouble with that method. Pick and choose (thats what I do) if its likely to become different seperate it off if its definetely going to be identicle use the idea you are using
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  9. #9
    Frenzied Member wiz126's Avatar
    Join Date
    Jul 2005
    Location
    Mars,Milky Way... Chit Chat Posts: 5,733
    Posts
    1,080

    Re: command1_click

    you need to make it public:
    VB Code:
    1. Public Sub Command1_click()
    1) If your post has been adequately answered please click in your post on "Mark Thread Resolved".
    2) If someone has been useful to you please show your respect by rating their posts.
    3) Please use [highlight="VB"] 'your code goes in here [/highlight] tags when posting code.
    4) Before posting your question, make sure you checked this links:
    MICROSOFT MSDN -- VB FORUMS SEARCH

    5)Support Classic VB - A PETITION TO MICROSOFT

    ___________________________________________________________________________________
    THINGS TO KNOW ABOUT VB: || VB Examples/Demos
    What are Classes?
    || -
    Where to place a sub/function?(global) || Webbrowser control

  10. #10
    Fanatic Member Dnereb's Avatar
    Join Date
    Aug 2005
    Location
    Netherlands
    Posts
    848

    Re: command1_click

    Quote Originally Posted by BodwadUK
    Just remember to update it when you update the other sub. Thats the only trouble with that method. Pick and choose (thats what I do) if its likely to become different seperate it off if its definetely going to be identicle use the idea you are using
    No, just use 1 subroutine/function and use this one in your CommandButton1_Click event as well as from another form.
    why can't programmers keep and 31 Oct and 25 dec apart. Why Rating is Useful
    for every question you ask provide an answer on another thread.

  11. #11
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176

    Re: command1_click

    hmm fair enough but it means running around when debugging
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  12. #12
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: command1_click

    Quote Originally Posted by BodwadUK
    hmm fair enough but it means running around when debugging
    You would do all your debugging in one spot. The Sub/Function.

    The various places that call it would not necessarily have to be changed/checked unless you needed to change any passed parameters.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  13. #13
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176

    Re: command1_click

    I have to reuse forms alot so it becomes problematic if you start intercrossing modules and forms in a huge mesh
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  14. #14
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,915

    Re: command1_click

    Quote Originally Posted by dee-u
    I have read somewhere that such method is slower...
    Oh... I read somewhere that it's much faster Anyway, how fast (or slow) is clicking a command button???

    I agree that if you have code that is being called from several different places, it makes more sense to place it in it's own sub. It's generally not a good idea to fill control event handlers with heaps of code anyway. Gets very messy.
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.