Function

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

Hy.
How Can I make Function which when I call this function
e.g. Call Star(10,20)
And I want that this function receive me any value.
***
***
Sample
Private sub Button_Click
Call Start(10,50) this function make 10+50 and
msgbox ( any variable with sum of this numbers.)
I want that this function receive me sum of this numbers.
end sub

Public Function Start(byval a as int32,byval b as int32)
c=a+b
end function

When I deklared c as Public I can make this msgbox(c), but I would like to
know if is any way to do this.
 
Hello, Mark:

You may want something like this:

\\\
Friend Function Start(ByVal a As Integer, ByVal b As Integer) As Integer
Return a+b
End Function

Private Sub Button_Click
Dim c As Integer
c=Start(10,50)
MsgBox(c.ToString)
'Or even:
MsgBox(Start(20, 30).ToString)
End Sub
///

Anyway you should buy (and read) a good VB beginners book, or read the VB documentation.

Regards.


"Mark" <[email protected]> escribió en el mensaje | Hy.
| How Can I make Function which when I call this function
| e.g. Call Star(10,20)
| And I want that this function receive me any value.
| ***
| ***
| Sample
| Private sub Button_Click
| Call Start(10,50) this function make 10+50 and
| msgbox ( any variable with sum of this numbers.)
| I want that this function receive me sum of this numbers.
| end sub
|
| Public Function Start(byval a as int32,byval b as int32)
| c=a+b
| end function
|
| When I deklared c as Public I can make this msgbox(c), but I would like to
| know if is any way to do this.
 
* "Mark said:
How Can I make Function which when I call this function
e.g. Call Star(10,20)
And I want that this function receive me any value.
***
***
Sample
Private sub Button_Click
Call Start(10,50) this function make 10+50 and
msgbox ( any variable with sum of this numbers.)
I want that this function receive me sum of this numbers.
end sub

Public Function Start(byval a as int32,byval b as int32)
c=a+b
end function

When I deklared c as Public I can make this msgbox(c), but I would like to
know if is any way to do this.

\\\
Public Function Start(ByVal a As Integer, ByVal b As Integer) As Integer
Return a + b
End Function
///

Usage:

\\\
Dim c As Integer = Start(10, 20)
///
 
Back
Top