Solved

VB.net Parameter Array

Posted on 2014-01-27
2
355 Views
Last Modified: 2014-01-27
Hi
In the following function I wanted to find out more about the part
ByVal ParamArray ColumnFields As String()
I have always parsed in single variables. How does this work

    Public Function PivotData(ByVal RowField As String, ByVal DataField As String, ByVal Aggregate As AggregateFunction, ByVal ParamArray ColumnFields As String()) As DataTable
        Dim dt As New DataTable()
0
Comment
Question by:murbro
2 Comments
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
ID: 39812059
Loosely based on the example here you could do something like this:
    Sub Main()
        '...

        PivotData("xxx", "yyy", func) ' the 'For Each' in PivotData() will not run

        PivotData("xxx", "yyy", func, "abc", "def") ' the 'For Each' will run twice, once for each of the arguments that follow the 3 fixed arguments

        '...
    End Sub

    Public Function PivotData(ByVal RowField As String, ByVal DataField As String, ByVal Aggregate As AggregateFunction, ByVal ParamArray ColumnFields As String()) As DataTable
        Dim dt As New DataTable()
        For Each ColumnField As String In ColumnFields
            dt.Columns.Add(ColumnField)
        Next
        Return dt
    End Function

Open in new window

0
 

Author Closing Comment

by:murbro
ID: 39814184
Thanks very much
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now