Changes

Creating Public and Private Functions in VB6

830 bytes added, 20:19, 10 January 2008
[[Functions in VB6]] moved to [[Creating Public and Private Functions in VB6]]
The following lines were added (+) and removed (-):
== Function Example ==== Standard Private Function == === example ===== Public Function in a Module ===== example ===You may want to create a function that is available to all forms in your program.  You can put it in a module and make it public so that it may be used by any form.MODULE CODE:  Public Function GetSettingEx(HKEY As Long, sPath As String, sValue As String)    Dim KeyHand&    Dim datatype&    Call RegOpenKey(HKEY, sPath, KeyHand&)    GetSettingEx = RegQueryStringValue(KeyHand&, sValue)    Call RegCloseKey(KeyHand&)  End FunctionFORM CODE:  strRetval = MODULE_NAME.GetSettingEx(HKEY_CURRENT_USER, "Software\album", "DefaultStorybookPath")=== troubleshooting ===* Compile Error: Method or data member not foundI bet you made the function "Private" instead of "Public".  Make sure the function in the module is a "Public Function".
Bureaucrat, administrator
14,711
edits