tags:

views:

96

answers:

1

I'm expecting a ByRef Argument Type Mismatch at compile time but I'm not getting it. It's compiling without errors and failing at runtime with error 13, "Type mismatch".

It's a fairly simple to reproduce.

dim c as Car
Set c = New Car

Sail c

...

Public Sub Sail(ByRef b As Boat)
    ...
End Sub

Car does not inherit from Boat

Is there a setting (or plugin perhaps) that will force VB into a strict compilation mode?

Edit: it looks like there's no compiler option for this. Does anyone know of an addon that analyses the source for these casting issues during a compile?

+3  A: 

Is it possible to set Option Strict True in VB6?

Edit: Apparently it is not possible in VB6 (seems to have been introduced with VB 7.0)

TheTXI
Yeah, this is possible.
Sukasa
No, sorry. Option Strict is not possible in VB6. Option Explicit is available but only ensures that you declare your variables, it does not prevent casting problems
tgmdbm
The link you posted was specific to VB.NET
tgmdbm
I noticed that immediately after I posted it, which is why I removed it.
TheTXI