Results 1 to 10 of 10

Thread: [Resolved] Error with some codes...

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2006
    Posts
    69

    Resolved [Resolved] Error with some codes...

    1- Suppose that I am working in form1... this code is not working:

    VB Code:
    1. Private sub command1_Click()
    2. form2.command2_Click
    3. End sub

    Is there any other way to do that?


    2- I used form properties to load a picture... but now I changed my mind and I don't want to load any picture... However, I tried to unload it!!! but I can't do that!!! This appears always and I can't delete it (Picture: (Bitamp))
    Last edited by XShadow; Oct 19th, 2006 at 12:52 PM.

  2. #2
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: Error with some codes...

    Quote Originally Posted by XShadow
    1- Suppose that I am working in form1... this code is not working:

    VB Code:
    1. Private sub command1_Click()
    2. form2.command2_Click
    3. End sub

    Is there any other way to do that?


    2- I used form properties to load a picture... but now I changed my mind and I don't want to load any picture... However, I tried to unload it!!! but I can't do that!!! This appears always and I can't delete it (Picture: (Bitamp))
    1) put the command2 code into a public sub (module) and then call the sub in the click event

    2) if you want to clear the forms picture property, do this:
    VB Code:
    1. Form1.Picture = LoadPicture("")

  3. #3

  4. #4
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: Error with some codes...

    Are you trying to call the click event? Then you should simply try:
    VB Code:
    1. Private Sub Command1_Click
    2.     Form2.Command2 = True
    3. End Sub

  5. #5
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Error with some codes...

    Quote Originally Posted by gavio
    Are you trying to call the click event? Then you should simply try:
    VB Code:
    1. Private Sub Command1_Click
    2.     Form2.Command2 = True
    3. End Sub
    See post #3

  6. #6
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Error with some codes...

    Quote Originally Posted by XShadow2
    2- I used form properties to load a picture... but now I changed my mind and I don't want to load any picture... However, I tried to unload it!!! but I can't do that!!! This appears always and I can't delete it (Picture: (Bitamp))
    Select the property, then press the Delete key twice.

  7. #7
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: Error with some codes...

    Quote Originally Posted by MartinLiss
    See post #3
    Yeah, but there's no need to change it to Public

    edit: Btw... form2.command2_Click = True doesn't work for me, even if Command2_Click is Public.

  8. #8
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: Error with some codes...

    Quote Originally Posted by gavio
    Yeah, but there's no need to change it to Public

    edit: Btw... form2.command2_Click = True doesn't work for me, even if Command2_Click is Public.
    .. but that will load Form2 in memory and you should not forget to unload it.

    Edit: Marty meant, make the Sub Public and under click event, just call the event name, ie. form2.command2_click
    Show Appreciation. Rate Posts.

  9. #9
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Error with some codes...

    Quote Originally Posted by gavio
    Yeah, but there's no need to change it to Public

    edit: Btw... form2.command2_Click = True doesn't work for me, even if Command2_Click is Public.
    You're right and what you need to do is

    Form2.Command2 = True

  10. #10
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: Error with some codes...

    Quote Originally Posted by Harsh Gupta
    .. but that will load Form2 in memory and you should not forget to unload it.
    True... but, if you have a form, don't you want to have it in the memory? If not, what's the point of it? You can always simply loop through all forms and unload each one when closing the app.

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