Unable to implement class in VB6

I am trying to implement an interface in VB6. I defined a class Cast_Speedlike this ...

Public Function Run_Time() As Long

End Function

and an implementation like this ...

Option Explicit
Implements Cast_Speed

Public Function Cast_Speed_Run_Time() As Long
    Cast_Speed_Run_Time = 0
End Function

but trying to compile it gives an "object module" to implement "Run_Time" for the Cast_Speed ​​interface. Can anyone see what I'm doing wrong? My routines seem to be all right, but all the functions I'm trying to do have this problem.

+5
source share
4 answers

The underscore in the method name is not like. Use instead RunTime().

I just tested it without underscore and it works fine for me:

'// class Cast_Speed
Option Explicit

Public Function RunTime() As Long

End Function


'// class Class1
Option Explicit

Implements Cast_Speed

Public Function Cast_Speed_RunTime() As Long
  Cast_Speed_RunTime = 0
End Function
+13
source

, , , , , . , VB6.:)

:

  • instancing - PublicNotCreatable.
  • .

:

Dim x as iMyInterface

x = new MyiMyInterfaceImplementation

x.CalliMyInterfaceMethodA

x.CalliMyInterfaceMethodY

. - , , - , , .

+4

, VB6 ( ).

:

Public Function Cast_Speed_Run_Time() As Long

To:

Private Function Cast_Speed_Run_Time() As Long

You can also read the implementation of interfaces in VB6 here (which seems to support me).

+2
source

All Articles