TaxControls Tutorial
Here we take you through the first steps in using TaxControls in your application. Be sure to select the appropriate platform below.
Set up the environment
- Download the evaluation software from here.
- 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).
- 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)'.
- Click 'OK'.
- Open a code window by selecting 'View | Code' from the menu
- Download the evaluation software from here.
- 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.
- 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'.
- Type the following at the resulting command prompt:
vsvars32.bat
which is installed with Visual Studio .NET. - 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.
<?phpinclude_once('taxes.php');...?>
Instantiate the TaxControls object
- Create and test the object by entering:
Dim ct as New CTaxControlct.ShowAboutBoxUnload Me
in the Form_Load routine of the code window.
- Run the code by pressing the 'F5' key. You should see ab About box similar to the following:
- End the program by clicking 'OK'.
- 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();}}
- Compile the code at the command prompt by executing the following:
javac -classpath .;bigloo_u.zip;TaxControls.jar Instantiate.java
- Run the program by typing:
java -classpath .;bigloo_u.zip;TaxControls.jar Instantiate
You should see ab About box similar to the following:
- End the program by clicking 'OK'.
- 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);}}
- Compile the code at the command prompt by executing the following:
csc /reference:TaxControls.dll Instantiate.cs
- Run the program by typing:
Instantiate
The program should print a version number on the console.
<?phpinclude_once('taxes.php');// federal income tax (note that the key is case sensitive):$t = $taxlist['FIT'];?>
Compute a withholding amount
- 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
- Run the code as above by pressing the 'F5' key. You should see a dialog box appear, indicating the computed amount.
- End the program by clicking 'OK'.
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).
- 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();}}}
- Compile the code at the command prompt by executing the following:
javac -classpath .;bigloo_u.zip;TaxControls.jar Compute.java
- 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.
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).
- 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());}}
- Compile the code at the command prompt by executing the following:
csc /reference:TaxControls.dll Compute.cs
- Run the program by typing:
Compute
The program should print a withholding amount on the console.
<?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
- 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
- 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.
- 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();}}}
- Compile the code at the command prompt by executing the following:
javac -classpath .;bigloo_u.zip;TaxControls.jar List.java
- 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.
- 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);}}}
- Compile the code at the command prompt by executing the following:
csc /reference:TaxControls.dll List.cs
- 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
- 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
- Run the code as above by pressing the 'F5' key. You should see all the state tax names listed in the 'Immediate' window.
- 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();}}}
- Compile the code at the command prompt by executing the following:
javac -classpath .;bigloo_u.zip;TaxControls.jar States.java
- 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.
- 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);}}}
- Compile the code at the command prompt by executing the following:
csc /reference:TaxControls.dll States.cs
- 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
- 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
- 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.
- End the program by clicking 'OK'.
- 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();}}}
- Compile the code at the command prompt by executing the following:
javac -classpath .;bigloo_u.zip;TaxControls.jar Zip.java
- 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).
- 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);}}
- Compile the code at the command prompt by executing the following:
csc /reference:TaxControls.dll Zips.cs
- 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().