TaxControls Tutorial

Tax Tables and Tax Table software

02/06/2012 Tax 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 language 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_u.zip' and 'TaxControls.jar' files.
    • On WindowsSet the classpath to .;bigloo_u.zip;TaxControls.jar
    • On Unix/LinuxSet the classpath to .:bigloo_u.zip:TaxControls.jar

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

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

    This command would run the demo (again on Windows)

    java -classpath .;bigloo_u.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.
All that is needed for PHP tables is a web server capable of serving up PHP5 files. If you plan to use the 'taxNamesForZip' function (see below), then your PHP installation must have the PDO module, with a sqlite driver. The PHP demo should be unzipped into a directory under the document root of the web server. The 'taxes.php' file should be included in your app page:

<?phpinclude_once('taxes.php');...?>

Instantiate the TaxControls object

  1. Create and test the object by entering:

    Dim ct as New CTaxControlct.ShowAboutBoxUnload 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_u.zip;TaxControls.jar Instantiate.java

  3. Run the program by typing:

    java -classpath .;bigloo_u.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.
Rather than a single TaxControls object, the PHP table supplies an array of instantiated tax objects called '$taxlist'. This array has a key value of the tax name, pointing to the instantiated object:

<?phpinclude_once('taxes.php');// federal income tax (note that the key is case sensitive):$t = $taxlist['FIT'];?>

Compute a withholding amount

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

    Dim ct as New CTaxControlct.DataFilename = "c:\Program Files\TaxControls\us2011.tax"ct.SelectedTax = "fit"ct.Earnings = 5000MsgBox ct.TaxAmountUnload 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_u.zip;TaxControls.jar Compute.java

  4. Run the program by typing:

    java -classpath .;bigloo_u.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.
You don't need a tax object or $taxlist to perform a calculation. Just call the top-level compute function:

<?phpinclude_once('taxes.php');$amt = compute('FIT', // tax name2000, // gross earnings0, // ytd earnings$filingSingle, // filing status (0=single)0, // exemptions0, // state exemptions12); // pay periods per year (12=monthly)?>

List available tax names

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

    Dim ct as New CTaxControlDim otax as Taxct.DataFilename = "c:\Program Files\TaxControls\us2005.tax"For Each otax in ct.TaxesDebug.Print otax.NameNextUnload 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_u.zip;TaxControls.jar List.java

  3. Run the program by typing:

    java -classpath .;bigloo_u.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.TaxesIEnumerator 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.

The $taxlist array contains all the tax classes. Just iterate over the array to generate the list:

...foreach($taxlist as $key => $tax){print $tax->name;}...

List state tax names

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

    Dim ct as New CTaxControlDim otax as Taxct.DataFilename = "c:\Program Files\TaxControls\us2005.tax"For Each otax in ct.TaxesIf otax.TaxType="S" Then Debug.Print otax.NameNextUnload 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_u.zip;TaxControls.jar States.java

  3. Run the program by typing:

    java -classpath .;bigloo_u.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.TaxesIEnumerator 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.

Filter the $taxlist, using only tax objects with type=='S':

...foreach($taxlist as $key => $tax){if ($tax->type=='S')print $tax->name;}...

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 CTaxControlct.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_u.zip;TaxControls.jar Zip.java

  3. Run the program by typing:

    java -classpath .;bigloo_u.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().

You can use the function 'taxNamesForZip' to get an array of suggested tax names for the employee:

...$workzip = 10001;$homezip = 7450;$a = taxNamesForZip($workzip, $homezip);foreach ($a as $taxname){$tax = $taxlist[$taxname]...}...

Note that Federal and Social Security taxes apply regardless of ZIP code, and are not returned by taxNamesForZip().

.