How to Call a Function as a argument in another Function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vijetaverma
    New Member
    • Mar 2007
    • 2

    How to Call a Function as a argument in another Function

    I am using Visual Studio and using this code in report Properties

    Code:
    Dim values As New System.Collection.ArrayList
    
    Function AddValues(newValue As Decimal) As Decimal
    values.Add(newValues)
    AddValues=newValues
    End Function
    
    Function GetMedian() As Decimal
    Dim count As Integer =values.Count
    If (count>0)
    values.Sort()
    GetMedian=values(count\2)
    End If
    End Function

    I am new to Function and i want 2 changes in this code
    1) i want to use newValue as Array in function AddValue
    2) i want to call AddValue in GetMedian Function as Argument
    because i want to calulate medians of list of arrays which are grouped in AddValue Function
    or
    tell me something to use by which i can group the (values)* by the field i want

    i hope you undertood what i am saying....Pleas e help me with this
    i need to solve this urgent
    Thanks in advance
    Vijeta
    Last edited by Killer42; Apr 6 '07, 11:19 PM. Reason: Please use [CODE]...[/CODE] tags around your code.
  • pongscript
    New Member
    • Mar 2007
    • 27

    #2
    correct me if i was wrong

    if you want to pass an array to a function your function structure should be


    public sub somthing(_value s as string())
    //operation
    end sub

    if your function must return the values then

    public function somthing(_value s as string()) as string()
    //operation
    return _values()
    end sub

    Comment

    • vijetaverma
      New Member
      • Mar 2007
      • 2

      #3
      Originally posted by pongscript
      correct me if i was wrong

      if you want to pass an array to a function your function structure should be


      public sub somthing(_value s as string())
      //operation
      end sub

      if your function must return the values then

      public function somthing(_value s as string()) as string()
      //operation
      return _values()
      end sub
      thanks for you reply i try apply this on my code hope it will work

      Comment

      • pongscript
        New Member
        • Mar 2007
        • 27

        #4
        sorry there was a mistake on the second to the last line... the return should be _values with out parenthesis...

        public sub somthing(_value s as string())
        //operation
        end sub

        if your function must return the values then

        public function somthing(_value s as string()) as string()
        //operation
        return _values
        end sub

        Comment

        Working...