VB6 Overloaded Methods


Author: Dave
Date: 03.21.16 - 1:40am



People can complain that vb6 does not contain the ability to overloaded methods.

Actually though, it can, the implementation is just a bit different.

Really, I prefer this mechanism over having to write a bunch of wrappers. I also love optional arguments with default values and would never give those up. With vb6 you get the best of both worlds.

Private Sub Form_Load()
    
    MsgBoxPlus &H11223344
    MsgBoxPlus Array("this is line 1", "and line 2 here")
    MsgBoxPlus "just a regular string!"
    MsgBoxPlus CCur(247.99)
    
End Sub

Sub MsgBoxPlus(msg As Variant)
    
    If TypeName(msg) = "Integer" Or TypeName(msg) = "Long" Then
        MsgBox Hex(msg)
    ElseIf IsArray(msg) Then
        MsgBox Join(msg, vbCrLf)
    Else
        MsgBox msg
    End If
    
End Sub





Comments: (0)

 
Leave Comment:
Name:
Email: (not shown)
Message: (Required)
Math Question: 50 + 35 = ? followed by the letter: N 



About Me
More Blogs
Main Site
Posts: (All)
2020 ( 2 )
2019 ( 5 )
2018 ( 6 )
2017 ( 6 )
2016 (22)
     VB6 CDECL
     UDT Tricks pt2
     Remote Data Extraction
     Collection Extender
     VB6 FindResource
     CDO.Message
     DirList Single Click
     Reset CheckPoint VPN Policy
     VB6 BSTR Oddities Explained
     SafeArrays in C
     BSTR and Variant in C++
     Property let optional args
     Misc Libs
     Enum Named Pipes
     Vb6 Collection in C++
     VB6 Overloaded Methods
     EXPORT FUNCDNAME Warning
     VB6 Syncronous Socket
     Simple IPC
     VB6 Auto Resize Form Elements
     Mach3 Automation
     Exit For in While
2015 ( 16 )
2014 ( 25 )
2013 ( 4 )
2012 ( 10 )
2011 ( 7 )
2010 ( 11 )
2009 ( 3 )