Filter Rows Example (VB.NET)
[VB.NET]
' COPYRIGHT(C), SIMPLEXAR SOFTWARE LIMITED, 2006-2008.
' All rights reserved.
'
' Use of this copyright notice is precautionary only, and does not imply
' publication or disclosure. The content of this work contains confidential
' and proprietary information of Simplexar Software Limited. Any duplication,
' modification, distribution, or disclosure in any form, in whole, or in part,
' is strictly prohibited without express prior written permission.
' Get namespaces.
Imports System
Imports Simplexar.Statsar
' Start namespace.
Namespace Simplexar.Examples.Statsar
' This example uses expressions to filter out unwanted rows from
' a data sheet. This method does not alter the data sheet. Instead
' a new data sheet with filtered rows is returned.
Module Example
' The application entry point.
Public Sub Main()
Try
RunExample()
Catch exception As Exception
Console.WriteLine(exception)
End Try
Console.WriteLine("Press ENTER to terminate.")
Console.ReadLine()
End Sub
Private Sub RunExample()
' Create a calculator.
Dim calculator As New StatsCalculator()
' Use the calculator to load the sheet.
Dim sheet As DataSheet = calculator.Load( _
"..\..\..\..\..\Data\Salaries.csv")
Console.WriteLine(sheet)
' Suppose we wish to filter this data to include only states
' with a salary of at least $60,000 or above. The expression
' we can use is: "Salary >= 60".
Dim filterSheet1 As DataSheet = sheet.Filter("Salary >= 60")
Console.WriteLine(filterSheet1)
' As a second example, suppose that instead of salaries of at
' least $60,000 we wanted to find out which states have a salary
' of between $45,000 and $55,000 inclusive. We could use the
' following expression to do this: "Salary >= 45 AND Salary <= 55"
' However, the expression syntax also supports the BETWEEN
' keyword, meaning that we can also use the following more
' readable expression: "Salary BETWEEN 45 AND 55".
Dim filterSheet2 As DataSheet _
= sheet.Filter("Salary BETWEEN 45 AND 55")
Console.WriteLine(filterSheet2)
End Sub
End Module
End Namespace