[Resolved] Error with some codes...
1- Suppose that I am working in form1... this code is not working:
VB Code:
Private sub command1_Click()
form2.command2_Click
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))
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:
Private sub command1_Click()
form2.command2_Click
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:
Form1.Picture = LoadPicture("")
Re: Error with some codes...
If you change command2_Click to a Public sub you can do
form2.command2_Click = True
Re: Error with some codes...
Are you trying to call the click event? Then you should simply try:
VB Code:
Private Sub Command1_Click
Form2.Command2 = True
End Sub
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:
Private Sub Command1_Click
Form2.Command2 = True
End Sub
See post #3
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.
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.
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
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 :blush: and what you need to do is
Form2.Command2 = True
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.