Passing parameters in functions...

Results 1 to 2 of 2

Thread: Passing parameters in functions...

  1. #1
    Join Date
    Dec 1969

    Default Passing parameters in functions...

    I have followed the instructions for passing parameters into functions, but the return value is not passed to the calling program as suggested in the documentation, as in the old VB6 program but I do not receive the value back from the function.<BR><BR>-------------------------------------------------<BR>Suggested format:<BR><BR>Function functionname[(argumentlist)] As datatype<BR> &#039; ...<BR> Return expression &#039;Control is returned immediately.<BR> &#039; ...<BR>End Function<BR><BR>------------------------------------------------------<BR>My Function...<BR><BR> Sub Main()<BR> Dim strName As String<BR> Dim intRandom, intGuess, intAttempts As Integer<BR><BR> GetRandomNumber(intRandom) &#039; Calling function with parameter<BR> End Sub<BR><BR>&#039;Called function<BR> Function GetRandomNumber(ByVal intRandom As Integer) As Integer<BR> Randomize()<BR> intRandom = CInt(Rnd() * 100) + 1<BR> Return intRandom<BR> End Function<BR><BR>------------------------------------------------------<BR>Anybody have an idea what is wrong here?

  2. #2
    Join Date
    Dec 1969

    Default RE: Passing parameters in functions...

    Yeah, you&#039;re not assigning the return value to a variable:<BR>Sub Main()<BR>Dim strName As String<BR>Dim intRandom, intGuess, intAttempts intReturn As Integer<BR><BR>intReturn = GetRandomNumber(intRandom) &#039; Calling function with parameter<BR>End Sub<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts