English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I am having the hardest time writing functions in visual basic. I understand that they DON'T return values as is; but the setting or parameters and ByVal have made me more confused. If possible, please, give an example of some sort.

2007-02-10 14:44:53 · 3 answers · asked by Answerz 4 in Computers & Internet Programming & Design

3 answers

Functions in VB return values !!
Sintaxis:

Function ( )
=
End Function


Examples:

Function AddValue(Num1 As Integer, num2 As Integer) As Integer
Dim nTot As Integer

nTot = Num1 + num2
AddValue = nTot
End Function

Function AddString(Str1 As String, Str2 As String) As String
AddString = Str1 & Str2
End Function


AddValue() function Acept 2 Integers types parameters "(Num1 As Integer, num2 As Integer)"
AddValue() function Return a Value of Integer type. "As Integer"
(To return a value, just assign the value to return to the function name " AddValue = nTot")


AddString() function Acept 2 Strings types parameters "(Str1 As String, Str2 As String)"
AddString() function Return a Value of String type. "As String"
(To return a value, just assign the value to return to the function name " AddString = Str1 & Str2")

2007-02-10 17:26:15 · answer #1 · answered by Anonymous · 1 0

MSDN has some examples ... Give them a try.

Functions *can* and *do* return values - after all,
that is what a function actually does, process an
input to give you an output, i.e.

Function: Input Value ==> process ==> Output

Try not to confuse Functions with Subroutines.


HTH

2007-02-10 15:00:32 · answer #2 · answered by Anonymous · 0 0

on your excelsheet, go with the cellular you like the consequence in. After doing this, hint your mouse to the long bar on suitable of the sheet, that feels like an address bar. There you will see an illustration that resembles an 'fx'. click on it, go with your needed function, go with your cells and you're waiting to circulate! take excitement in!

2016-11-03 03:01:47 · answer #3 · answered by ? 4 · 0 0

fedest.com, questions and answers