-
April 27th, 2004, 02:54 AM
#16
Re: Re: send some code please
Originally posted by Colt_777
what is the 'me' part for in vb? i've seen this alot but i don't have a clue what it's about.
Me ?
it references the form or object you are currently in...
if you have Form1 and you write code in Form_load (for example)
you can say : Form1.DoSomthing or Me.DoSomething
Me works much like this pointer in C++ if this can help..
-
April 27th, 2004, 02:57 AM
#17
Me keyword
Originally posted by Colt_777
what is the 'me' part for in vb?
Explain a bit better...Are you referring t o the "Me" keyword?
If so, the Me is a way to refer to the instance of the object inside
the object.
Ie:
in a form, named Form1,
Me -inside code of Form1 -is near equivalent of Form1
thus
Me.Cls is = to Form1.Cls
but that is not all:
if you load the form this way:
dim frmX as Form1
set frmX = new Form1
if inside Form1 you write:
Me.Cls, this will work on FrmX (=that particular instance of Form1)
while if you write Form1.Cls, inside that instance it will not clear
the graphics in frmX instance, it will ...Load Form1!
...
Thus:
Code:
If frmX.Hwnd<> Me.Hwnd then
will work both if you called the form, or if you create an instance
of it....
in conclusion:
when writing code inside a form for that form and you need to
refer to taht for itself, take the habit to use "Me" instead of using
the form name...
Last edited by Cimperiali; April 27th, 2004 at 03:03 AM.
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
-
April 27th, 2004, 03:00 AM
#18
Have a look at this thread, there is example code & instruction on where to place & how to call...
-
April 27th, 2004, 07:14 AM
#19
forgot to mention this
I forgot to tell you that i'm using the "End" command only when i want to close the main form and exit the program. The other forms are still using the "Unload Me" command to close. Is this less dangerous for my program?
-
April 27th, 2004, 08:32 AM
#20
Put code I gave you in the query_unload (or, if you really do not
find it, in the unload) event of your main form. Where you
coded "End" code instead: "Unload Me"
Code:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
'if you have any timers, disable
'them here
'If you have any loop with a Doevents
'you need to set a boolean to true here
'and check the value in loop to know you're
'quitting and thus exit the loop there
'Put here the code I wrote
End Sub
Private Sub Command1_Click()
'instead of End code:
Unload me
End Sub
About less dangerous:
all depends on what is not closing
Using End will terminate abruptly. Like if you, to turn off yout Pc,
simply cut off energy instead of using the "Shut down" option via
code. As long as your program does not have file or connections
opened, and as long as called components could close in any
case when caller disappear (but this may not be in your hands),
you could survive. But remember: it is really a bad practice...
Last edited by Cimperiali; April 27th, 2004 at 08:37 AM.
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
-
April 27th, 2004, 12:34 PM
#21
it's working
Thanks a million Cimperiali I've done what u said and it's working now.
Also i've tried the code Dmorley mentioned and that too is working. It's more like Cimperiali 's code, but more simple.
So anyway, my program is closing like is supposed to close...normally.
Thanks for helping us "little guys"
-
April 28th, 2004, 06:34 AM
#22
Thanks for feedback
Have happy coding,
Cesare I.
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|