VB6 Class Init ParamsAuthor: Dave Date: 03.14.18 - 4:24am Some people, myself included, wished vb6 allowed you to set some default parameters when you first create a class. Its just a small shortcut but its handy, especially if you have to set like 5-6 parameters. Upon further reflection this is a non-issue. VB.net dim c as new class1(1,"dog") c.someMethod()Honestly though it doesn't take much foresight to reduce the vb6 code down to 2 lines as well which is functionally equivalent. Consider the following: Dim c As New Class1 Call c.init(1, "dog").someMethod Public index Public name Function init(i, n) As Class1 index = i name = n Set init = Me End Function Function someMethod() MsgBox "Index: " & index & " Name: " & name End Function Universally default parameters of course are still set in class_initialize. Comments: (0) |
About Me More Blogs Main Site
|
||||||||||||||||||||||||||||