Hello
When creating a function or sub procedure what purpose does the data type
declaration outside of the parameter list after the parenthesis on the end
serve?
for example Public Sub mypgm(Byval fld1 as integer) as string
It's purpose is to allow a method to return a value after it is
finished processing.
For Example:
////////////////////
Public Function IsUserValid(ByVal userName As String) As Boolean
If (the user is valid) Then
Return True
Else
Return False
End If
End Function
Public Sub Foo()
Dim isValid As Boolean = IsUserValid("Seth Rowe")
If isValid Then
MsgBox("Seth Rowe is a Valid User")
Else
MsgBox("Seth Rowe is not a Valid User")
End If
End Sub
///////////////////
The code to check whether a given name is a valid user has been
encapsulated into the IsUserValid method. Any other method can now
pass in a string to this function and will receive a boolean value
from the method that will indicate whether the user is, or isn't,
valid. Other examples are methods that might construct an object, such
as a DataTable. In general, the constructed DataTable will be created
in the method and returned as a return value (Public Function
BuildDT() As DataTable).
Thanks,
Seth Rowe