TaxControls Tutorial

Tax Tables and Tax Table software

07/04/2008Tax Table software, components and data for computing payroll withholding amounts.

Skip to: Site menu | Main content

TaxControls Tutorial

Here we take you through the first steps in using TaxControls in your application. Be sure to select the appropriate platform below.

<= Select a programming environment here

Set up the environment

  1. Download the evaluation software from here.
  2. Start up Visual Basic and start a new project. From the menu select 'File | New Project', highlight the 'Standard EXE' icon and click OK (here we use VB6).
  3. Insert a project reference to the TaxControls ActiveX Dll. From the menu select 'Project | References', and in the resulting dialog scroll down and enable the entry 'TaxControls ActiveX Dll (ATL version)'.
  4. Click 'OK'.
  5. Open a code window by selecting 'View | Code' from the menu
  1. Download the evaluation software from here.
  2. Set up the classpath. To use the TaxControl component, your classpath must include both the 'bigloo_s.zip' and 'TaxControls.jar' files.
    • On Windows Set the classpath to .;bigloo_s.zip;TaxControls.jar
    • On Unix/Linux Set the classpath to .:bigloo_s.zip:TaxControls.jar

    For example, this command would compile the demo on Windows:

    javac -classpath .;bigloo_s.zip;TaxControls.jar Demo.java

    This command would run the demo (again on Windows)

    java -classpath .;bigloo_s.zip;TaxControls.jar Demo

    Several possible methods can be used to compile and execute code on the .NET platform, including Microsoft's Visual Studio .NET, and the Mono project. For this tutorial, we will use the command-line tools available with Visual Studio.
  1. Open a command-line window by selecting Start | Run... from the Windows desktop. When the Run dialog box opens, type 'cmd' in the input field, then click 'OK'.
  2. Type the following at the resulting command prompt:

    vsvars32.bat

    which is installed with Visual Studio .NET.
  3. Type the following line to ensure that your environment is set up correctly:

    csc /?

    You should see the help information for the C# compiler on the console.

Instantiate the TaxControls object

  1. Create and test the object by entering:

    Dim ct as New CTaxControl ct.ShowAboutBox Unload Me

    in the Form_Load routine of the code window.

  2. Run the code by pressing the 'F5' key. You should see ab About box similar to the following:
  3. End the program by clicking 'OK'.
  1. Create and test the object. In file named 'Instantiate.java', enter the following:

    import com.boondocks.taxcontrols.TaxControl; public class Instantiate{ public static void main(String[] args){ TaxControl tc = new TaxControl(); tc.showAboutBox(); } }

  2. Compile the code at the command prompt by executing the following:

    javac -classpath .;bigloo_s.zip;TaxControls.jar Instantiate.java

  3. Run the program by typing:

    java -classpath .;bigloo_s.zip;TaxControls.jar Instantiate

    You should see ab About box similar to the following:
  4. End the program by clicking 'OK'.
  1. Create and test the object. In file named 'Instantiate.cs', enter the following:

    using System; using TaxControls; class Test{ public static void Main(){ CTaxControl tc = new CTaxControl(); Console.WriteLine(tc.SoftwareVersion); } }

  2. Compile the code at the command prompt by executing the following:

    csc /reference:TaxControls.dll Instantiate.cs

  3. Run the program by typing:

    Instantiate

    The program should print a version number on the console.

Compute a withholding amount

  1. Enter the following code in a code window (as above, in the Form_Load routine):

    Dim ct as New CTaxControl ct.DataFilename = "c:\Program Files\TaxControls\us2005.tax" ct.SelectedTax = "fit" ct.Earnings = 5000 MsgBox ct.TaxAmount Unload Me

  2. This minimal code chooses the tax table data file, sets the earnings per pay period to $5000, and computes the tax. Default values were taken for YTDEarnings ($0), Exemptions (0), FilingStatus (0 = Single), and PayPeriodsPerYear (12 = monthly).

  3. Run the code as above by pressing the 'F5' key. You should see a dialog box appear, indicating the computed amount.
  4. End the program by clicking 'OK'.
  1. Enter the following code in the file 'Compute.java':

    import com.boondocks.taxcontrols.TaxControl; import com.boondocks.taxcontrols.TaxControlException; public class Compute{ public static void main(String[] args){ TaxControl tc = new TaxControl(); tc.setDataFilename("us2004.tax"); tc.setEarnings(5000.0); try{ System.out.println(tc.getTaxAmount()); } catch (TaxControlException e){ e.printStackTrace(); } } }

  2. This minimal code chooses the tax table data file, sets the earnings per pay period to $5000, and computes the tax. Default values were taken for YTDEarnings ($0), Exemptions (0), FilingStatus (0 = Single), and PayPeriodsPerYear (12 = monthly).

  3. Compile the code at the command prompt by executing the following:

    javac -classpath .;bigloo_s.zip;TaxControls.jar Compute.java

  4. Run the program by typing:

    java -classpath .;bigloo_s.zip;TaxControls.jar Compute

    You should see the computed Federal income tax print out on the console.
  1. Enter the following code in file named 'Compute.cs', enter the following:

    using System; using TaxControls; class Test{ public static void Main(){ CTaxControl tc = new CTaxControl(); tc.DataFilename = "us2004.tax"; tc.SelectedTax = "fit"; tc.Earnings = 5000.00; Console.WriteLine(tc.TaxAmount()); } }

  2. Compile the code at the command prompt by executing the following:

    csc /reference:TaxControls.dll Compute.cs

  3. Run the program by typing:

    Compute

    The program should print a withholding amount on the console.

List available tax names

  1. Enter the following code in a code window (as above, in the Form_Load routine):

    Dim ct as New CTaxControl Dim otax as Tax ct.DataFilename = "c:\Program Files\TaxControls\us2005.tax" For Each otax in ct.Taxes Debug.Print otax.Name Next Unload Me

  2. Run the code as above by pressing the 'F5' key. You should see output in the 'Immediate' window. If necessary, type 'Ctrl-G' to show this window.
  1. Enter the following code in the file 'List.java':

    import com.boondocks.taxcontrols.TaxControl; import com.boondocks.taxcontrols.Taxes; import com.boondocks.taxcontrols.Tax; import com.boondocks.taxcontrols.TaxControlException; import java.util.Enumeration; public class List{ public static void main(String[] args){ TaxControl tc = new TaxControl(); tc.setDataFilename("us2004.tax"); try{ Taxes txs = tc.getTaxes(); for (Enumeration e = txs.elements() ; e.hasMoreElements() ;) { Tax t = (Tax)e.nextElement(); System.out.println(t.getName()); } } catch (TaxControlException e){ e.printStackTrace(); } } }

  2. Compile the code at the command prompt by executing the following:

    javac -classpath .;bigloo_s.zip;TaxControls.jar List.java

  3. Run the program by typing:

    java -classpath .;bigloo_s.zip;TaxControls.jar List

    You should see the names of many taxes print out on the console, in no particular order.
  1. Enter the following code in file named 'List.cs', enter the following:

    using System; using System.Collections; using TaxControls; class Test{ public static void Main(){ CTaxControl tc = new CTaxControl(); tc.DataFilename = "us2004.tax"; Taxes txs = tc.Taxes IEnumerator inr = txs.GetEnumerator(); while(inr.MoveNext()){ Tax t = (Tax) inr.Current; Console.WriteLine(t.Name); } } }

  2. Compile the code at the command prompt by executing the following:

    csc /reference:TaxControls.dll List.cs

  3. Run the program by typing:

    List

    The program should print many tax names on the console.

List state tax names

  1. Enter the following code in a code window (as above, in the Form_Load routine):

    Dim ct as New CTaxControl Dim otax as Tax ct.DataFilename = "c:\Program Files\TaxControls\us2005.tax" For Each otax in ct.Taxes If otax.TaxType="S" Then Debug.Print otax.Name Next Unload Me

  2. Run the code as above by pressing the 'F5' key. You should see all the state tax names listed in the 'Immediate' window.
  1. Enter the following code in the file 'States.java':

    import com.boondocks.taxcontrols.TaxControl; import com.boondocks.taxcontrols.Taxes; import com.boondocks.taxcontrols.Tax; import com.boondocks.taxcontrols.TaxControlException; import java.util.Enumeration; public class States{ public static void main(String[] args){ TaxControl tc = new TaxControl(); tc.setDataFilename("us2004.tax"); try{ Taxes txs = tc.getTaxes(); for (Enumeration e = txs.elements() ; e.hasMoreElements() ;) { Tax t = (Tax)e.nextElement(); if (t.getTaxType().equals("S")) System.out.println(t.getName()); } } catch (TaxControlException e){ e.printStackTrace(); } } }

  2. Compile the code at the command prompt by executing the following:

    javac -classpath .;bigloo_s.zip;TaxControls.jar States.java

  3. Run the program by typing:

    java -classpath .;bigloo_s.zip;TaxControls.jar States

    You should see the names of many taxes print out on the console, in no particular order.
  1. Enter the following code in file named 'States.cs', enter the following:

    using System; using System.Collections; using TaxControls; class Test{ public static void Main(){ CTaxControl tc = new CTaxControl(); tc.DataFilename = "us2004.tax"; Taxes txs = tc.Taxes IEnumerator inr = txs.GetEnumerator(); while(inr.MoveNext()){ Tax t = (Tax) inr.Current; if (t.TaxType == "S") Console.WriteLine(t.Name); } } }

  2. Compile the code at the command prompt by executing the following:

    csc /reference:TaxControls.dll States.cs

  3. Run the program by typing:

    States

    The program should print the state tax names on the console.

Look up taxes for a ZIP code

  1. Enter the following code in a code window (as above, in the Form_Load routine):

    Dim ct as New CTaxControl ct.DataFilename = "c:\Program Files\TaxControls\us2005.tax" MsgBox ct.TaxNamesForZip( 10001, 10001) Unload Me

  2. Run the code as above by pressing the 'F5' key. You should see a dialog box containing a comma-delimited list of state and local tax names.
  3. End the program by clicking 'OK'.
  1. Enter the following code in the file 'Zip.java':

    import com.boondocks.taxcontrols.TaxControl; import com.boondocks.taxcontrols.Taxes; import com.boondocks.taxcontrols.Tax; import com.boondocks.taxcontrols.TaxControlException; import java.util.Enumeration; public class Zip{ public static void main(String[] args){ TaxControl tc = new TaxControl(); tc.setDataFilename("us2004.tax"); try{ // Employee lives and works in Ohio: Taxes txs = tc.getTaxesForZip(44139, 44145); for (Enumeration e = txs.elements() ; e.hasMoreElements() ;) { Tax t = (Tax)e.nextElement(); System.out.println(t.getName()); } } catch (TaxControlException e){ e.printStackTrace(); } } }

  2. Compile the code at the command prompt by executing the following:

    javac -classpath .;bigloo_s.zip;TaxControls.jar Zip.java

  3. Run the program by typing:

    java -classpath .;bigloo_s.zip;TaxControls.jar Zip

    You should see the names some local or state taxes print on the console. (The federal taxes 'fit', 'fica-ss', and 'fica-med' apply to all ZIP codes, and are not returned by this method).
  1. Enter the following code in file named 'Zips.cs', enter the following:

    using System; using TaxControls; class Test{ public static void Main(){ CTaxControl tc = new CTaxControl(); tc.DataFilename = "us2004.tax"; String s = tc.TaxNamesForZip(44139, 44145); Console.WriteLine(s); } }

  2. Compile the code at the command prompt by executing the following:

    csc /reference:TaxControls.dll Zips.cs

  3. Run the program by typing:

    Zips

    The program should print a comma-delimited string of tax names on the console. Note that Federal and Social Security taxes apply regardless of ZIP code, and are not returned by TaxNamesForZip().
.