Forum Discussion
- gid_216Frequent ContributorSubroutine and function have same defination, throughout all tools these can't be differenciated based on tool.
Subroutine is a piece of reusable code that doesn't return anything to caller.
Function is a piece of reusable code that returns something to caller. - gid_216Frequent ContributorFunction can return any thing like Variant, Array, Object etc. If the function returns an object, as caller end function is assinged to a variable using Set.
E.g.
If Function F1 retuns an object.
Function F2
Set var1=F1(Arg List)
End Function - sathish_subrama_2New ContributorCould you please explain in detail, what exactly function will return?
- sastoweSuper ContributorVBScript example
Sub DoIt
set btn = ...VBObject("cmdSave")
btn.Click
End Sub
Clicks a button
sPadMyString = LeftPad("a", "1", 3)
Function LeftPad(sValuetoPad, sPadChar, iPadLength)
LeftPad = string(iPadLength - Len(sValuetoPad),sPadChar) & sValuetoPad
End function 'LeftPad
Related Content
- 5 years ago
Recent Discussions
- 16 hours ago