VB6 Overloaded MethodsAuthor: 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) |
About Me More Blogs Main Site
|
||||||||||||||||||||||||||||||||||||||