tags:

views:

54

answers:

3

I'd like to create an object... say a "Movie" object. The object should have a method name "Stop", so I can have this code below

dim Mov as new Movie
Mov.Stop ' To execute the Stop method.

In my Movie class, I should have something like this.

Sub Stop()
'code here needed for the Stop subroutine
End Sub

However, I can't use "Stop" as name as this is a reserved word. I see a VB code that has "Stop" as one of the method. Unfortunately, the code is protected so I can't view it.

How can I name a subroutine as "Stop"?

A: 

Stop is a keyword in Vb6. You will have to rename your method to something different. Say MovieStop

J Angwenyi
just my 2 cents StopMovie will be more appropriate.
vikramjb
+2  A: 

Stop is a statement used to break the app when debugging (same as setting a breakpoint) so choose another name.

Alex K.
As I said, I saw a VB code that has a "Stop" method in it. There should be a way to define it.
Kratz
VB could call a method called .Stop from a library written in something other than VB where Stop is not reserved (or one written in VB with a custom typelib perhaps) but you can't create a method in VB6 called `Stop` any more than you could create a `Sub Dim()`.
Alex K.
+1 You can work round some of the naming restrictions in VB6 by enclosing identifiers in brackets ([ ]). But not this one - choose another name.
MarkJ
+1  A: 

It might work if you created a typelib with Stop and your other methods and properties and then use Implements in your class. I haven't tested this though.

Bob Riemersma
+1 … That will work.
Konrad Rudolph
Thanks for verifying this. I can use it myself, often wanting a Close method or such. Hmm, I suppose it doesn't even have to be complete, just cover the members with the reserved word collisions you may have.
Bob Riemersma