Solved

VB.net Parameter Array

Posted on 2014-01-27
2
356 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

895 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