Need help looping through a dataset

EStallworth

Well-known member
Joined
Aug 14, 2006
Messages
75
Location
Destin, FL
Programming Experience
Beginner
I am developing a form that will be able to add new account information to a database. The ID values auto increment but my account numbers do not because the type of account varies. I have used a dataadapter to fill a dataset with all existing account numbers and am working on looping through the dataset in order to compare the user entered account number to the current numbers in use. Any help would be appreciated.

VB.NET:
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] acct [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = AcctCodeTextBox.Text[/SIZE]
 
[SIZE=2][SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] i [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2] = 0 [/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2] DataSet501.Tables([/SIZE][SIZE=2][COLOR=#800000]"Org"[/COLOR][/SIZE][SIZE=2]).Rows.Count - 1[/SIZE]
[SIZE=2][COLOR=#0000ff]If [/COLOR][/SIZE][SIZE=2]acct = DataSet501.Tables([/SIZE][SIZE=2][COLOR=#800000]"Org"[/COLOR][/SIZE][SIZE=2]).Rows(i).Item([/SIZE][SIZE=2][COLOR=#800000]"AcctCode"[/COLOR][/SIZE][SIZE=2]).ToString [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]TextBox1.Text = [/SIZE][SIZE=2][COLOR=#800000]"Please choose another account number."[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE]
[/SIZE]
 
If you create a unique index on your AccountCode field in your database it will not allow the same AccountCode numbers. It will reject it and send an error message the accountCode already exists. You can catch this error and report it back to the user. Imagine if you had a multi-client app sharing the same database. Two users with the same AccountCode could be checking your client method looking for duplicates against a dataset they have loaded in their memory. The records could be added and you would never know they had the same accountCode.
 
Last edited:
I suppose if you wanted to go the direction you are heading then you can just use the executescalar method, or SELECT DISTINCT based on the id that the user entered. If no row gets returned from the query then you can assume that it is not present in the database, if one does then inform the user that the id already exists. I wouldn't go down the road of catching exceptions, best to aviod them at all costs, they are more expensive that doing a round trip to a database.
 
I am developing a form that will be able to add new account information to a database. The ID values auto increment but my account numbers do not because the type of account varies.

Erm, i'm not sure how sensible that is - is there any harm in letting account numbers increment? bank account numbers do, and noone has the same account number regardless of the type of account they hold or at which branch they hold it

Do you mean to say that your system can have, e.g. a Red, Green or Blue type account, and it would be possible for me to open one of each, and I be account number 1 in all of them?

If it must be this way, then you are free to make a combination of columns account number and account type to be unique in a table. I would advise you make them the primary key, and it will do away with the need for the ID field too


If you could fill your question out with some more info about your database setup, it would be good.

I have used a dataadapter to fill a dataset with all existing account numbers and am working on looping through the dataset in order to compare the user entered account number to the current numbers in use.

Bringing this logic to the client side is a really bad idea. Essentially you have a software called a database that is incredibly good at looking things up, and instead you choose to use it as a data storage, load all its data into your client, and then write the lookup logic yourself. This creates more work for you and is unlikely to realise the same level of performance as a database lookup would; microsoft/oracle/ibm/etc have industry experts slaving for years to create the fastest performing lookups so they can claim their database is faster than XYZ - while I dont mean to sound harsh, I dont think there is anything you or I can do in a couple of days, to write a faster search than they spent years doing :)

VB.NET:
[COLOR=#0000ff]For[/COLOR][SIZE=2] i [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2] = 0 [/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2] DataSet501.Tables([/SIZE][SIZE=2][COLOR=#800000]"Org"[/COLOR][/SIZE][SIZE=2]).Rows.Count - 1[/SIZE]
[SIZE=2][COLOR=#0000ff]If [/COLOR][/SIZE][SIZE=2]acct = DataSet501.Tables([/SIZE][SIZE=2][COLOR=#800000]"Org"[/COLOR][/SIZE][SIZE=2]).Rows(i).Item([/SIZE][SIZE=2][COLOR=#800000]"AcctCode"[/COLOR][/SIZE][SIZE=2]).ToString [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]TextBox1.Text = [/SIZE][SIZE=2][COLOR=#800000]"Please choose another account number."[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE]

You are using typed datasets; i wouldnt recommend reverting to untyped access modes. the following code is quicker and more secure. Also, intellisense can help you write the following code, but it cant help you write the untyped stuff (your version):

VB.NET:
If acct Is Nothing Or acct.Equals("") Then
 ''message box to tell them to type something
  Return
endif 
 
For Each ro as OrgDataRow in DataSet501.Org
  If acct.Equals(ro.AcctCode) Then
    ''tell them to pick another
    Return 'dont forget to exit the method!
  EndIf
Next

The typed (and by that i dont mean pressing keys on a keyboard, i mean Strong-Typing vs Weak-Typing in Object Orientation) code is much neater, and doesnt require extraneous tostringing etc

Do please consider what Vis and I said though - that you should get the db to do the lookup.
 
Do you mean to say that your system can have, e.g. a Red, Green or Blue type account, and it would be possible for me to open one of each, and I be account number 1 in all of them?

Yes this is the scenario I am dealing with.

If you could fill your question out with some more info about your database setup, it would be good.

I am not sure what all infor you would need... I am using SQL server 2k. My primary key is an ID field. This is what I am using to pull values from accounts through various forms/objects.

Bringing this logic to the client side is a really bad idea. Essentially you have a software called a database that is incredibly good at looking things up, and instead you choose to use it as a data storage, load all its data into your client, and then write the lookup logic yourself. This creates more work for you and is unlikely to realise the same level of performance as a database lookup would; microsoft/oracle/ibm/etc have industry experts slaving for years to create the fastest performing lookups so they can claim their database is faster than XYZ - while I dont mean to sound harsh, I dont think there is anything you or I can do in a couple of days, to write a faster search than they spent years doing :)

HARSH WORDS DUDE! j/j :) . I know you are trying to help and this is the type of reality check I need! I realize that the logic being on the client side is a bad idea, but I have very little experience with SQL and anytime I try to write my own queries it takes a while for me to get the syntax down, I use command builders due to this, and always come up with a boatload of errors that I post here.:( I need to work on it more.


You are using typed datasets; i wouldnt recommend reverting to untyped access modes. the following code is quicker and more secure. Also, intellisense can help you write the following code, but it cant help you write the untyped stuff (your version):

VB.NET:
If acct Is Nothing Or acct.Equals("") Then
 ''message box to tell them to type something
  Return
endif 
 
For Each ro as OrgDataRow in DataSet501.Org
  If acct.Equals(ro.AcctCode) Then
    ''tell them to pick another
    Return 'dont forget to exit the method!
  EndIf
Next

The typed (and by that i dont mean pressing keys on a keyboard, i mean Strong-Typing vs Weak-Typing in Object Orientation) code is much neater, and doesnt require extraneous tostringing etc

Do please consider what Vis and I said though - that you should get the db to do the lookup.

Thanks for the example code and I know the difference between Strong and Weak typed just not enough to implement it a lot. I will continue to work on using the db to do the grunt work for me. Thanks to both of you for all your continuing help to the newb!
 
Yes this is the scenario I am dealing with.

Hmm. Pity you cant bash the designer a bit, but hey.. if youre stuck with it..

Right. In this scneario in Oracle (and im sure SQL server has this too) we use something called a sequence. Think of it like that counter clicker a bouncer has on the club door for counting people in. Every time you select a value from it, it rolls up by one. You can look at the current value all you want without changing it.

Your primary key field is an ID, OK, but a better candidate exists in the form of two columns: Colour, and Account (my example)
Making Colour, Account the compound primary key ensures that noone gets the same Red #1 account number, but Red#1 Green#1 and Blue#1 can exist happily

Next we would make 3 sequence counters, one for red, one green, one blue

Each time we insert a record, we take the next value from the relevant counter:

In oracle parameterized query this would be:

VB.NET:
INSERT INTO ACCOUNT(colour, accno, name)
SELECT 
  :colour, 
  decode(:colour, 'blue', blue_sequence.nextval, 'red', red_sequence.nextval, 'green', green_sequence.nextval),
  :name
FROM
  dual

Sequences dont exist in SQL server, but there are pages on the web with info on how you can simulate them. It might necessitate that your update logic goes into a stored procedure, but the IDE can help you write that.



I realize that the logic being on the client side is a bad idea, but I have very little experience with SQL and anytime I try to write my own queries it takes a while for me to get the syntax down, I use command builders due to this, and always come up with a boatload of errors that I post here.:( I need to work on it more.

Learning the SQL is a long, hard process, but it is well worth it.. honest! It's a shame that all you have available is sql server - I used to think SQL Server was nice, till i used Oracle - if I had a major development to do now, I think i'd use Oracle Express rather then sql server; there's just too much about SQLS that is overly primitive, i find..



Thanks for the example code and I know the difference between Strong and Weak typed just not enough to implement it a lot. I will continue to work on using the db to do the grunt work for me. Thanks to both of you for all your continuing help to the newb!
Intellisense is the biggest help.. just type dataset501, thena period, and take a look... :)
 
VB.NET:
If acct Is Nothing Or acct.Equals("") Then
 ''message box to tell them to type something
  Return
endif 
 
For Each ro as OrgDataRow in DataSet501.Org
  If acct.Equals(ro.AcctCode) Then
    ''tell them to pick another
    [B][U]Return 'dont forget to exit the method![/U][/B]
  EndIf
Next

I did not exit any of the methods within any of my IF statements(didn't know I needed to) and once I saw your post I went and placed "Return" within all of them. Afterwards I received functionality problems and do not know why. The only thing I recognized was that my value was not being passed from one textbox to the other and once I commented the "Returns" out of the statements it worked fine. I am about to read into it right now, but if you could see any reason why this is so I would appreciate it. Thx.

VB.NET:
[SIZE=2][COLOR=#0000ff]Try[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] i = 1 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]id = ComboBox1.SelectedValue[/SIZE]
[SIZE=2]acctnum = ComboBox1.Text[/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].names = Label28.Text[/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].periods = Val(ComboBox2.Text)[/SIZE]
[SIZE=2]status1 = Label67.Text[/SIZE]
[SIZE=2]numunits = Val(availabletxt.Text)[/SIZE]
[SIZE=2]numrented = Val(rentedtxt.Text)[/SIZE]
[SIZE=2]duedates = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(duedatelabel.Text)[/SIZE]
[SIZE=2]returntypes = returntypelabel.Text[/SIZE]
[SIZE=2]postingdates = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(postdatetxt.Text)[/SIZE]
[SIZE=2]paymentdates = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(paydatetxt.Text)[/SIZE]
[SIZE=2]receiptdates = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(receiptdatetxt.Text)[/SIZE]
[SIZE=2]checknum = Val(checknumtxt.Text)[/SIZE]
[SIZE=2]checkamt = Val(checkamttxt.Text)[/SIZE]
[SIZE=2]gross = Val(grosstxt.Text)[/SIZE]
[SIZE=2]exempt = Val(exempttxt.Text)[/SIZE]
[SIZE=2]taxable = Val(taxabletxt.Text)[/SIZE]
[SIZE=2]adjust = Val(adjusttxt.Text)[/SIZE]
[SIZE=2]total = Val(totalduetxt.Text)[/SIZE]
[SIZE=2]collection = Val(collectiontxt.Text)[/SIZE]
[SIZE=2]penalties = Val(penaltytxt.Text)[/SIZE]
[SIZE=2]interests = Val(interesttxt.Text)[/SIZE]
[SIZE=2]totalamounts = Val(amountduetxt.Text)[/SIZE]
[SIZE=2]totalspaid = Val(totalpaidtxt.Text)[/SIZE]
[SIZE=2]returnbalances = Val(returnbaltxt.Text)[/SIZE]
[SIZE=2]acctbalance = Val(accountbaltxt.Text)[/SIZE]
[SIZE=2][COLOR=#0000ff]ElseIf[/COLOR][/SIZE][SIZE=2] i = 2 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]id1 = ComboBox1.SelectedValue[/SIZE]
[SIZE=2]acctnum1 = ComboBox1.Text[/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].names1 = Label28.Text[/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].periods1 = Val(ComboBox2.Text)[/SIZE]
[SIZE=2]status2 = Label67.Text[/SIZE]
[SIZE=2]numunits1 = Val(availabletxt.Text)[/SIZE]
[SIZE=2]numrented1 = Val(rentedtxt.Text)[/SIZE]
[SIZE=2]duedates1 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(duedatelabel.Text)[/SIZE]
[SIZE=2]returntypes1 = returntypelabel.Text[/SIZE]
[SIZE=2]postingdates1 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(postdatetxt.Text)[/SIZE]
[SIZE=2]paymentdates1 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(paydatetxt.Text)[/SIZE]
[SIZE=2]receiptdates1 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(receiptdatetxt.Text)[/SIZE]
[SIZE=2]checknum1 = Val(checknumtxt.Text)[/SIZE]
[SIZE=2]checkamt1 = Val(checkamttxt.Text)[/SIZE]
[SIZE=2]gross1 = Val(grosstxt.Text)[/SIZE]
[SIZE=2]exempt1 = Val(exempttxt.Text)[/SIZE]
[SIZE=2]taxable1 = Val(taxabletxt.Text)[/SIZE]
[SIZE=2]adjust1 = Val(adjusttxt.Text)[/SIZE]
[SIZE=2]total1 = Val(totalduetxt.Text)[/SIZE]
[SIZE=2]collection1 = Val(collectiontxt.Text)[/SIZE]
[SIZE=2]penalties1 = Val(penaltytxt.Text)[/SIZE]
[SIZE=2]interests1 = Val(interesttxt.Text)[/SIZE]
[SIZE=2]totalamounts1 = Val(amountduetxt.Text)[/SIZE]
[SIZE=2]totalspaid1 = Val(totalpaidtxt.Text)[/SIZE]
[SIZE=2]returnbalances1 = Val(returnbaltxt.Text)[/SIZE]
[SIZE=2]acctbalance1 = Val(accountbaltxt.Text)[/SIZE]
[SIZE=2][COLOR=#0000ff]ElseIf[/COLOR][/SIZE][SIZE=2] i = 3 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]id2 = ComboBox1.SelectedValue[/SIZE]
[SIZE=2]acctnum2 = ComboBox1.Text[/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].names2 = Label28.Text[/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].periods2 = Val(ComboBox2.Text)[/SIZE]
[SIZE=2]status3 = Label67.Text[/SIZE]
[SIZE=2]numunits2 = Val(availabletxt.Text)[/SIZE]
[SIZE=2]numrented2 = Val(rentedtxt.Text)[/SIZE]
[SIZE=2]duedates2 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(duedatelabel.Text)[/SIZE]
[SIZE=2]returntypes2 = returntypelabel.Text[/SIZE]
[SIZE=2]postingdates2 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(postdatetxt.Text)[/SIZE]
[SIZE=2]paymentdates2 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(paydatetxt.Text)[/SIZE]
[SIZE=2]receiptdates2 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(receiptdatetxt.Text)[/SIZE]
[SIZE=2]checknum2 = Val(checknumtxt.Text)[/SIZE]
[SIZE=2]checkamt2 = Val(checkamttxt.Text)[/SIZE]
[SIZE=2]gross2 = Val(grosstxt.Text)[/SIZE]
[SIZE=2]exempt2 = Val(exempttxt.Text)[/SIZE]
[SIZE=2]taxable2 = Val(taxabletxt.Text)[/SIZE]
[SIZE=2]adjust2 = Val(adjusttxt.Text)[/SIZE]
[SIZE=2]total2 = Val(totalduetxt.Text)[/SIZE]
[SIZE=2]collection2 = Val(collectiontxt.Text)[/SIZE]
[SIZE=2]penalties2 = Val(penaltytxt.Text)[/SIZE]
[SIZE=2]interests2 = Val(interesttxt.Text)[/SIZE]
[SIZE=2]totalamounts2 = Val(amountduetxt.Text)[/SIZE]
[SIZE=2]totalspaid2 = Val(totalpaidtxt.Text)[/SIZE]
[SIZE=2]returnbalances2 = Val(returnbaltxt.Text)[/SIZE]
[SIZE=2]acctbalance2 = Val(accountbaltxt.Text)[/SIZE]
[SIZE=2][COLOR=#0000ff]ElseIf[/COLOR][/SIZE][SIZE=2] i = 4 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]id3 = ComboBox1.SelectedValue[/SIZE]
[SIZE=2]acctnum3 = ComboBox1.Text[/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].names3 = Label28.Text[/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].periods3 = Val(ComboBox2.Text)[/SIZE]
[SIZE=2]status4 = Label67.Text[/SIZE]
[SIZE=2]numunits3 = Val(availabletxt.Text)[/SIZE]
[SIZE=2]numrented3 = Val(rentedtxt.Text)[/SIZE]
[SIZE=2]duedates3 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(duedatelabel.Text)[/SIZE]
[SIZE=2]returntypes3 = returntypelabel.Text[/SIZE]
[SIZE=2]postingdates3 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(postdatetxt.Text)[/SIZE]
[SIZE=2]paymentdates3 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(paydatetxt.Text)[/SIZE]
[SIZE=2]receiptdates3 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(receiptdatetxt.Text)[/SIZE]
[SIZE=2]checknum3 = Val(checknumtxt.Text)[/SIZE]
[SIZE=2]checkamt3 = Val(checkamttxt.Text)[/SIZE]
[SIZE=2]gross3 = Val(grosstxt.Text)[/SIZE]
[SIZE=2]exempt3 = Val(exempttxt.Text)[/SIZE]
[SIZE=2]taxable3 = Val(taxabletxt.Text)[/SIZE]
[SIZE=2]adjust3 = Val(adjusttxt.Text)[/SIZE]
[SIZE=2]total3 = Val(totalduetxt.Text)[/SIZE]
[SIZE=2]collection3 = Val(collectiontxt.Text)[/SIZE]
[SIZE=2]penalties3 = Val(penaltytxt.Text)[/SIZE]
[SIZE=2]interests3 = Val(interesttxt.Text)[/SIZE]
[SIZE=2]totalamounts3 = Val(amountduetxt.Text)[/SIZE]
[SIZE=2]totalspaid3 = Val(totalpaidtxt.Text)[/SIZE]
[SIZE=2]returnbalances3 = Val(returnbaltxt.Text)[/SIZE]
[SIZE=2]acctbalance3 = Val(accountbaltxt.Text)[/SIZE]
[SIZE=2][COLOR=#0000ff]ElseIf[/COLOR][/SIZE][SIZE=2] i = 5 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]id4 = ComboBox1.SelectedValue[/SIZE]
[SIZE=2]acctnum4 = ComboBox1.Text[/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].names4 = Label28.Text[/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].periods4 = Val(ComboBox2.Text)[/SIZE]
[SIZE=2]status5 = Label67.Text[/SIZE]
[SIZE=2]numunits4 = Val(availabletxt.Text)[/SIZE]
[SIZE=2]numrented4 = Val(rentedtxt.Text)[/SIZE]
[SIZE=2]duedates4 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(duedatelabel.Text)[/SIZE]
[SIZE=2]returntypes4 = returntypelabel.Text[/SIZE]
[SIZE=2]postingdates4 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(postdatetxt.Text)[/SIZE]
[SIZE=2]paymentdates4 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(paydatetxt.Text)[/SIZE]
[SIZE=2]receiptdates4 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(receiptdatetxt.Text)[/SIZE]
[SIZE=2]checknum4 = Val(checknumtxt.Text)[/SIZE]
[SIZE=2]checkamt4 = Val(checkamttxt.Text)[/SIZE]
[SIZE=2]gross4 = Val(grosstxt.Text)[/SIZE]
[SIZE=2]exempt4 = Val(exempttxt.Text)[/SIZE]
[SIZE=2]taxable4 = Val(taxabletxt.Text)[/SIZE]
[SIZE=2]adjust4 = Val(adjusttxt.Text)[/SIZE]
[SIZE=2]total4 = Val(totalduetxt.Text)[/SIZE]
[SIZE=2]collection4 = Val(collectiontxt.Text)[/SIZE]
[SIZE=2]penalties4 = Val(penaltytxt.Text)[/SIZE]
[SIZE=2]interests4 = Val(interesttxt.Text)[/SIZE]
[SIZE=2]totalamounts4 = Val(amountduetxt.Text)[/SIZE]
[SIZE=2]totalspaid4 = Val(totalpaidtxt.Text)[/SIZE]
[SIZE=2]returnbalances4 = Val(returnbaltxt.Text)[/SIZE]
[SIZE=2]acctbalance4 = Val(accountbaltxt.Text)[/SIZE]
[SIZE=2][COLOR=#0000ff]ElseIf[/COLOR][/SIZE][SIZE=2] i = 6 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]id5 = ComboBox1.SelectedValue[/SIZE]
[SIZE=2]acctnum5 = ComboBox1.Text[/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].names5 = Label28.Text[/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].periods5 = Val(ComboBox2.Text)[/SIZE]
[SIZE=2]status6 = Label67.Text[/SIZE]
[SIZE=2]numunits5 = Val(availabletxt.Text)[/SIZE]
[SIZE=2]numrented5 = Val(rentedtxt.Text)[/SIZE]
[SIZE=2]duedates5 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(duedatelabel.Text)[/SIZE]
[SIZE=2]returntypes5 = returntypelabel.Text[/SIZE]
[SIZE=2]postingdates5 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(postdatetxt.Text)[/SIZE]
[SIZE=2]paymentdates5 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(paydatetxt.Text)[/SIZE]
[SIZE=2]receiptdates5 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(receiptdatetxt.Text)[/SIZE]
[SIZE=2]checknum5 = Val(checknumtxt.Text)[/SIZE]
[SIZE=2]checkamt5 = Val(checkamttxt.Text)[/SIZE]
[SIZE=2]gross5 = Val(grosstxt.Text)[/SIZE]
[SIZE=2]exempt5 = Val(exempttxt.Text)[/SIZE]
[SIZE=2]taxable5 = Val(taxabletxt.Text)[/SIZE]
[SIZE=2]adjust5 = Val(adjusttxt.Text)[/SIZE]
[SIZE=2]total5 = Val(totalduetxt.Text)[/SIZE]
[SIZE=2]collection5 = Val(collectiontxt.Text)[/SIZE]
[SIZE=2]penalties5 = Val(penaltytxt.Text)[/SIZE]
[SIZE=2]interests5 = Val(interesttxt.Text)[/SIZE]
[SIZE=2]totalamounts5 = Val(amountduetxt.Text)[/SIZE]
[SIZE=2]totalspaid5 = Val(totalpaidtxt.Text)[/SIZE]
[SIZE=2]returnbalances5 = Val(returnbaltxt.Text)[/SIZE]
[SIZE=2]acctbalance5 = Val(accountbaltxt.Text)[/SIZE]
[SIZE=2][COLOR=#0000ff]ElseIf[/COLOR][/SIZE][SIZE=2] i = 7 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]id6 = ComboBox1.SelectedValue[/SIZE]
[SIZE=2]acctnum6 = ComboBox1.Text[/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].names6 = Label28.Text[/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].periods6 = Val(ComboBox2.Text)[/SIZE]
[SIZE=2]status7 = Label67.Text[/SIZE]
[SIZE=2]numunits6 = Val(availabletxt.Text)[/SIZE]
[SIZE=2]numrented6 = Val(rentedtxt.Text)[/SIZE]
[SIZE=2]duedates6 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(duedatelabel.Text)[/SIZE]
[SIZE=2]returntypes6 = returntypelabel.Text[/SIZE]
[SIZE=2]postingdates6 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(postdatetxt.Text)[/SIZE]
[SIZE=2]paymentdates6 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(paydatetxt.Text)[/SIZE]
[SIZE=2]receiptdates6 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(receiptdatetxt.Text)[/SIZE]
[SIZE=2]checknum6 = Val(checknumtxt.Text)[/SIZE]
[SIZE=2]checkamt6 = Val(checkamttxt.Text)[/SIZE]
[SIZE=2]gross6 = Val(grosstxt.Text)[/SIZE]
[SIZE=2]exempt6 = Val(exempttxt.Text)[/SIZE]
[SIZE=2]taxable6 = Val(taxabletxt.Text)[/SIZE]
[SIZE=2]adjust6 = Val(adjusttxt.Text)[/SIZE]
[SIZE=2]total6 = Val(totalduetxt.Text)[/SIZE]
[SIZE=2]collection6 = Val(collectiontxt.Text)[/SIZE]
[SIZE=2]penalties6 = Val(penaltytxt.Text)[/SIZE]
[SIZE=2]interests6 = Val(interesttxt.Text)[/SIZE]
[SIZE=2]totalamounts6 = Val(amountduetxt.Text)[/SIZE]
[SIZE=2]totalspaid6 = Val(totalpaidtxt.Text)[/SIZE]
[SIZE=2]returnbalances6 = Val(returnbaltxt.Text)[/SIZE]
[SIZE=2]acctbalance6 = Val(accountbaltxt.Text)[/SIZE]
[SIZE=2][COLOR=#0000ff]ElseIf[/COLOR][/SIZE][SIZE=2] i = 8 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]id7 = ComboBox1.SelectedValue[/SIZE]
[SIZE=2]acctnum7 = ComboBox1.Text[/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].names7 = Label28.Text[/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].periods7 = Val(ComboBox2.Text)[/SIZE]
[SIZE=2]status8 = Label67.Text[/SIZE]
[SIZE=2]numunits7 = Val(availabletxt.Text)[/SIZE]
[SIZE=2]numrented7 = Val(rentedtxt.Text)[/SIZE]
[SIZE=2]duedates7 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(duedatelabel.Text)[/SIZE]
[SIZE=2]returntypes7 = returntypelabel.Text[/SIZE]
[SIZE=2]postingdates7 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(postdatetxt.Text)[/SIZE]
[SIZE=2]paymentdates7 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(paydatetxt.Text)[/SIZE]
[SIZE=2]receiptdates7 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(receiptdatetxt.Text)[/SIZE]
[SIZE=2]checknum7 = Val(checknumtxt.Text)[/SIZE]
[SIZE=2]checkamt7 = Val(checkamttxt.Text)[/SIZE]
[SIZE=2]gross7 = Val(grosstxt.Text)[/SIZE]
[SIZE=2]exempt7 = Val(exempttxt.Text)[/SIZE]
[SIZE=2]taxable7 = Val(taxabletxt.Text)[/SIZE]
[SIZE=2]adjust7 = Val(adjusttxt.Text)[/SIZE]
[SIZE=2]total7 = Val(totalduetxt.Text)[/SIZE]
[SIZE=2]collection7 = Val(collectiontxt.Text)[/SIZE]
[SIZE=2]penalties7 = Val(penaltytxt.Text)[/SIZE]
[SIZE=2]interests7 = Val(interesttxt.Text)[/SIZE]
[SIZE=2]totalamounts7 = Val(amountduetxt.Text)[/SIZE]
[SIZE=2]totalspaid7 = Val(totalpaidtxt.Text)[/SIZE]
[SIZE=2]returnbalances7 = Val(returnbaltxt.Text)[/SIZE]
[SIZE=2]acctbalance7 = Val(accountbaltxt.Text)[/SIZE]
[SIZE=2][COLOR=#0000ff]ElseIf[/COLOR][/SIZE][SIZE=2] i = 9 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]id8 = ComboBox1.SelectedValue[/SIZE]
[SIZE=2]acctnum8 = ComboBox1.Text[/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].names8 = Label28.Text[/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].periods8 = Val(ComboBox2.Text)[/SIZE]
[SIZE=2]status9 = Label67.Text[/SIZE]
[SIZE=2]numunits8 = Val(availabletxt.Text)[/SIZE]
[SIZE=2]numrented8 = Val(rentedtxt.Text)[/SIZE]
[SIZE=2]duedates8 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(duedatelabel.Text)[/SIZE]
[SIZE=2]returntypes8 = returntypelabel.Text[/SIZE]
[SIZE=2]postingdates8 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(postdatetxt.Text)[/SIZE]
[SIZE=2]paymentdates8 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(paydatetxt.Text)[/SIZE]
[SIZE=2]receiptdates8 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(receiptdatetxt.Text)[/SIZE]
[SIZE=2]checknum8 = Val(checknumtxt.Text)[/SIZE]
[SIZE=2]checkamt8 = Val(checkamttxt.Text)[/SIZE]
[SIZE=2]gross8 = Val(grosstxt.Text)[/SIZE]
[SIZE=2]exempt8 = Val(exempttxt.Text)[/SIZE]
[SIZE=2]taxable8 = Val(taxabletxt.Text)[/SIZE]
[SIZE=2]adjust8 = Val(adjusttxt.Text)[/SIZE]
[SIZE=2]total8 = Val(totalduetxt.Text)[/SIZE]
[SIZE=2]collection8 = Val(collectiontxt.Text)[/SIZE]
[SIZE=2]penalties8 = Val(penaltytxt.Text)[/SIZE]
[SIZE=2]interests8 = Val(interesttxt.Text)[/SIZE]
[SIZE=2]totalamounts8 = Val(amountduetxt.Text)[/SIZE]
[SIZE=2]totalspaid8 = Val(totalpaidtxt.Text)[/SIZE]
[SIZE=2]returnbalances8 = Val(returnbaltxt.Text)[/SIZE]
[SIZE=2]acctbalance8 = Val(accountbaltxt.Text)[/SIZE]
[SIZE=2][COLOR=#0000ff]ElseIf[/COLOR][/SIZE][SIZE=2] i = 10 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]id9 = ComboBox1.SelectedValue[/SIZE]
[SIZE=2]acctnum9 = ComboBox1.Text[/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].names9 = Label28.Text[/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].periods9 = Val(ComboBox2.Text)[/SIZE]
[SIZE=2]status10 = Label67.Text[/SIZE]
[SIZE=2]numunits9 = Val(availabletxt.Text)[/SIZE]
[SIZE=2]numrented9 = Val(rentedtxt.Text)[/SIZE]
[SIZE=2]duedates9 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(duedatelabel.Text)[/SIZE]
[SIZE=2]returntypes9 = returntypelabel.Text[/SIZE]
[SIZE=2]postingdates9 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(postdatetxt.Text)[/SIZE]
[SIZE=2]paymentdates9 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(paydatetxt.Text)[/SIZE]
[SIZE=2]receiptdates9 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(receiptdatetxt.Text)[/SIZE]
[SIZE=2]checknum9 = Val(checknumtxt.Text)[/SIZE]
[SIZE=2]checkamt9 = Val(checkamttxt.Text)[/SIZE]
[SIZE=2]gross9 = Val(grosstxt.Text)[/SIZE]
[SIZE=2]exempt9 = Val(exempttxt.Text)[/SIZE]
[SIZE=2]taxable9 = Val(taxabletxt.Text)[/SIZE]
[SIZE=2]adjust9 = Val(adjusttxt.Text)[/SIZE]
[SIZE=2]total9 = Val(totalduetxt.Text)[/SIZE]
[SIZE=2]collection9 = Val(collectiontxt.Text)[/SIZE]
[SIZE=2]penalties9 = Val(penaltytxt.Text)[/SIZE]
[SIZE=2]interests9 = Val(interesttxt.Text)[/SIZE]
[SIZE=2]totalamounts9 = Val(amountduetxt.Text)[/SIZE]
[SIZE=2]totalspaid9 = Val(totalpaidtxt.Text)[/SIZE]
[SIZE=2]returnbalances9 = Val(returnbaltxt.Text)[/SIZE]
[SIZE=2]acctbalance9 = Val(accountbaltxt.Text)[/SIZE]
[SIZE=2][COLOR=#0000ff]ElseIf[/COLOR][/SIZE][SIZE=2] i = 11 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]id10 = ComboBox1.SelectedValue[/SIZE]
[SIZE=2]acctnum10 = ComboBox1.Text[/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].names10 = Label28.Text[/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].periods10 = Val(ComboBox2.Text)[/SIZE]
[SIZE=2]status11 = Label67.Text[/SIZE]
[SIZE=2]numunits10 = Val(availabletxt.Text)[/SIZE]
[SIZE=2]numrented10 = Val(rentedtxt.Text)[/SIZE]
[SIZE=2]duedates10 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(duedatelabel.Text)[/SIZE]
[SIZE=2]returntypes10 = returntypelabel.Text[/SIZE]
[SIZE=2]postingdates10 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(postdatetxt.Text)[/SIZE]
[SIZE=2]paymentdates10 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(paydatetxt.Text)[/SIZE]
[SIZE=2]receiptdates10 = [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Parse(receiptdatetxt.Text)[/SIZE]
[SIZE=2]checknum10 = Val(checknumtxt.Text)[/SIZE]
[SIZE=2]checkamt10 = Val(checkamttxt.Text)[/SIZE]
[SIZE=2]gross10 = Val(grosstxt.Text)[/SIZE]
[SIZE=2]exempt10 = Val(exempttxt.Text)[/SIZE]
[SIZE=2]taxable10 = Val(taxabletxt.Text)[/SIZE]
[SIZE=2]adjust10 = Val(adjusttxt.Text)[/SIZE]
[SIZE=2]total10 = Val(totalduetxt.Text)[/SIZE]
[SIZE=2]collection10 = Val(collectiontxt.Text)[/SIZE]
[SIZE=2]penalties10 = Val(penaltytxt.Text)[/SIZE]
[SIZE=2]interests10 = Val(interesttxt.Text)[/SIZE]
[SIZE=2]totalamounts10 = Val(amountduetxt.Text)[/SIZE]
[SIZE=2]totalspaid10 = Val(totalpaidtxt.Text)[/SIZE]
[SIZE=2]returnbalances10 = Val(returnbaltxt.Text)[/SIZE]
[SIZE=2]acctbalance10 = Val(accountbaltxt.Text)[/SIZE]
[SIZE=2][COLOR=#008000]'Return[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Catch[/COLOR][/SIZE][SIZE=2] ex [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Exception[/SIZE]
[SIZE=2]MessageBox.Show(ex.Message)[/SIZE]
[SIZE=2][COLOR=#008000]'will need to take this exception out once error checking is complete...[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Try[/COLOR][/SIZE]
 
 
 
 
[SIZE=2][COLOR=#008000]'grossreceipts = Decimal.Round(CType(grosstxt.Text, Decimal), 2) 'enter gross receipts manually in order to pass the value to a variable[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'exemptreceipts = Decimal.Round(CType(exempttxt.Text, Decimal), 2)[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'taxablereceipts = Decimal.Round(grossreceipts - exemptreceipts, 2) 'calculates taxable receipts[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'taxabletxt.Text = Decimal.Round(taxablereceipts, 2) 'sets the visible text value of the textbox to the taxable receipts value[/COLOR][/SIZE]
[SIZE=2]taxb4adjust = taxablereceipts * 0.04 [/SIZE][SIZE=2][COLOR=#008000]'Decimal.Round(taxablereceipts, 2) ' declares a new vaiable to hold value of tax before the adjustments, penalties, etc...(do not believe this is a needed step, TBD)[/COLOR][/SIZE]
[SIZE=2]taxb4adjtxt.Text = [/SIZE][SIZE=2][COLOR=#0000ff]Decimal[/COLOR][/SIZE][SIZE=2].Round(taxb4adjust, 2) [/SIZE][SIZE=2][COLOR=#008000]' sets the visible property of the textbox to the tax before adjustments value[/COLOR][/SIZE]
[SIZE=2]auditb4adjustlabel.Text = [/SIZE][SIZE=2][COLOR=#0000ff]Decimal[/COLOR][/SIZE][SIZE=2].Round(taxb4adjust, 2)[/SIZE]
 
[SIZE=2][COLOR=#008000]'If Val(previousadjustlabel.Text) = 0 Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'adjustments = Val(adjusttxt.Text)[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Else[/COLOR][/SIZE]
[SIZE=2]adjustments = [/SIZE][SIZE=2][COLOR=#0000ff]Decimal[/COLOR][/SIZE][SIZE=2].Round([/SIZE][SIZE=2][COLOR=#0000ff]CType[/COLOR][/SIZE][SIZE=2](previousadjustlabel.Text, [/SIZE][SIZE=2][COLOR=#0000ff]Decimal[/COLOR][/SIZE][SIZE=2]), 2) [/SIZE][SIZE=2][COLOR=#008000]'label holds previous balance adjustments that have not been paid previously(need dataset defining previous fees for certain account in order to draw those unpaid values)[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'End If[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] adjustments < 0 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE][SIZE=2][COLOR=#008000]'if they owe[/COLOR][/SIZE]
[SIZE=2]dueadjustlabel.Text = adjustments * -1[/SIZE]
[SIZE=2]differenceadjustlabel.Text = [/SIZE][SIZE=2][COLOR=#0000ff]Decimal[/COLOR][/SIZE][SIZE=2].Round(adjustments, 2) - Val(adjusttxt.Text)[/SIZE]
[SIZE=2]auditadjustmentslabel.Text = adjustments [/SIZE][SIZE=2][COLOR=#008000]'Val(dueadjustlabel.Text) - Val(previousadjustlabel.Text)[/COLOR][/SIZE]
[SIZE=2]totaltax = (taxb4adjust - adjustments) - Val(previoustotalduelabel.Text)[/SIZE]
[SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE]
[SIZE=2]dueadjustlabel.Text = [/SIZE][SIZE=2][COLOR=#800000]"0.00"[/COLOR][/SIZE][SIZE=2][COLOR=#008000]' if we owe[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'adjustments = -(adjustments)[/COLOR][/SIZE]
[SIZE=2]differenceadjustlabel.Text = adjustments + Val(adjusttxt.Text) [/SIZE][SIZE=2][COLOR=#008000]'Decimal.Round(-adjustments, 2) + Val(adjusttxt.Text) ',2)[/COLOR][/SIZE]
[SIZE=2]auditadjustmentslabel.Text = Val(dueadjustlabel.Text) + Val(previousadjustlabel.Text)[/SIZE]
[SIZE=2]totaltax = (taxb4adjust - adjustments) - Val(previoustotalduelabel.Text) [/SIZE][SIZE=2][COLOR=#008000]'was adding the value of the label, but the value being received should always be negative -(-)=+[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Return[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
 
 
[SIZE=2]totalduetxt.Text = [/SIZE][SIZE=2][COLOR=#0000ff]Decimal[/COLOR][/SIZE][SIZE=2].Round(totaltax, 2) [/SIZE][SIZE=2][COLOR=#008000]' sets the visible property of the textbox to the variable totaltax[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'If Val(previoustotalduelabel.Text) < 0 Then[/COLOR][/SIZE]
[SIZE=2]audittotalduelabel.Text = totaltax - Val(previoustotalduelabel.Text)[/SIZE]
[SIZE=2][COLOR=#008000]'ElseIf Val(previoustotalduelabel.Text) > 0 Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'End If[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] totaltax <= 1200 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE][SIZE=2][COLOR=#008000]' if statement to determine whether the collection allowance will be 2.5% or $30 and also takes into account any old allowances due[/COLOR][/SIZE]
[SIZE=2]collectionallowance = (totaltax * 0.025) - Val(previouscollectionlabel.Text) [/SIZE][SIZE=2][COLOR=#008000]' ""[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE]
[SIZE=2]collectionallowance = 30.0 [/SIZE][SIZE=2][COLOR=#008000]'- Val(previouscollectionlabel.Text) ' ""[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Return[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
 
[SIZE=2]duecollectionlabel.Text = [/SIZE][SIZE=2][COLOR=#0000ff]Decimal[/COLOR][/SIZE][SIZE=2].Round(collectionallowance, 2) [/SIZE][SIZE=2][COLOR=#008000]' sets the visible text property to the value of the collectionallowance variable[/COLOR][/SIZE]
[SIZE=2]auditcollectionlabel.Text = Val(duecollectionlabel.Text)[/SIZE]
 
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] Val(duecollectionlabel.Text) < 0 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] difference [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Decimal[/COLOR][/SIZE]
[SIZE=2]difference = Val(duecollectionlabel.Text) + Val(collectiontxt.Text)[/SIZE]
[SIZE=2]differencecollectionlabel.Text = [/SIZE][SIZE=2][COLOR=#0000ff]Decimal[/COLOR][/SIZE][SIZE=2].Round(difference, 2)[/SIZE]
[SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] difference [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Decimal[/COLOR][/SIZE]
[SIZE=2]difference = Val(collectiontxt.Text) - [/SIZE][SIZE=2][COLOR=#0000ff]CType[/COLOR][/SIZE][SIZE=2](duecollectionlabel.Text, [/SIZE][SIZE=2][COLOR=#0000ff]Decimal[/COLOR][/SIZE][SIZE=2]) [/SIZE][SIZE=2][COLOR=#008000]'right now both the values in this row show positive(one should show negative until evened out)[/COLOR][/SIZE]
[SIZE=2]differencecollectionlabel.Text = [/SIZE][SIZE=2][COLOR=#0000ff]Decimal[/COLOR][/SIZE][SIZE=2].Round(difference, 2)[/SIZE]
[SIZE=2][COLOR=#008000]'Return[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'this is starting point for positive/negative calculations[/COLOR][/SIZE]
 
 
[SIZE=2]interestperiod = Val(ComboBox2.Text) [/SIZE][SIZE=2][COLOR=#008000]'may need dataset to call account periods to display, if so a combobox is required instead of a textbox else this can be left up to the user to insert manually[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'changed the above line to read from the new combobox instead of a textbox[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#008000]'this IF statement will determine what period the return is for and what the interest percentages are [/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] interestperiod >= 200001 [/SIZE][SIZE=2][COLOR=#0000ff]And[/COLOR][/SIZE][SIZE=2] interestperiod <= 200112 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]interest = 0.12[/SIZE]
[SIZE=2]dailyinterest = 0.000327869[/SIZE]
[SIZE=2][COLOR=#0000ff]ElseIf[/COLOR][/SIZE][SIZE=2] interestperiod >= 200201 [/SIZE][SIZE=2][COLOR=#0000ff]And[/COLOR][/SIZE][SIZE=2] interestperiod <= 200206 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]interest = 0.11[/SIZE]
[SIZE=2]dailyinterest = 0.00030137[/SIZE]
[SIZE=2][COLOR=#0000ff]ElseIf[/COLOR][/SIZE][SIZE=2] interestperiod >= 200207 [/SIZE][SIZE=2][COLOR=#0000ff]And[/COLOR][/SIZE][SIZE=2] interestperiod <= 200306 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]interest = 0.09[/SIZE]
[SIZE=2]dailyinterest = 0.000246575[/SIZE]
[SIZE=2][COLOR=#0000ff]ElseIf[/COLOR][/SIZE][SIZE=2] interestperiod >= 200307 [/SIZE][SIZE=2][COLOR=#0000ff]And[/COLOR][/SIZE][SIZE=2] interestperiod <= 200506 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]interest = 0.08[/SIZE]
[SIZE=2]dailyinterest = 0.000219178[/SIZE]
[SIZE=2][COLOR=#0000ff]ElseIf[/COLOR][/SIZE][SIZE=2] interestperiod >= 200507 [/SIZE][SIZE=2][COLOR=#0000ff]And[/COLOR][/SIZE][SIZE=2] interestperiod <= 200512 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]interest = 0.09[/SIZE]
[SIZE=2]dailyinterest = 0.000246575[/SIZE]
[SIZE=2][COLOR=#0000ff]ElseIf[/COLOR][/SIZE][SIZE=2] interestperiod >= 200601 [/SIZE][SIZE=2][COLOR=#0000ff]And[/COLOR][/SIZE][SIZE=2] interestperiod <= 200606 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]interest = 0.1[/SIZE]
[SIZE=2]dailyinterest = 0.000273973[/SIZE]
[SIZE=2][COLOR=#0000ff]ElseIf[/COLOR][/SIZE][SIZE=2] interestperiod >= 200607 [/SIZE][SIZE=2][COLOR=#0000ff]And[/COLOR][/SIZE][SIZE=2] interestperiod <= 200612 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]interest = 0.11[/SIZE]
[SIZE=2]dailyinterest = 0.00030137[/SIZE]
[SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Try[/COLOR][/SIZE]
[SIZE=2]interest = InputBox([/SIZE][SIZE=2][COLOR=#800000]"Please Enter the Current Interest Amount"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]dailyinterest = InputBox([/SIZE][SIZE=2][COLOR=#800000]"Please Calculate and Enter the Interest Accrued on a Daily Basis"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]interestperiod = InputBox([/SIZE][SIZE=2][COLOR=#800000]"Please Define the Current Interest Period"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]ComboBox2.Text = interestperiod[/SIZE]
[SIZE=2][COLOR=#0000ff]Catch[/COLOR][/SIZE][SIZE=2] ex [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Exception[/SIZE]
[SIZE=2]MsgBox([/SIZE][SIZE=2][COLOR=#800000]"You must enter an interest amount, a daily interest amount and an interest period in order for calculations to be valid."[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] interest = 0 [/SIZE][SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][SIZE=2] Str(interest) = [/SIZE][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Do[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]While[/COLOR][/SIZE][SIZE=2] interest = 0 [/SIZE][SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][SIZE=2] Str(interest) = [/SIZE][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Try[/COLOR][/SIZE]
[SIZE=2]interest = InputBox([/SIZE][SIZE=2][COLOR=#800000]"Please Enter the Current Interest Amount"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]Catch[/COLOR][/SIZE][SIZE=2] ex1 [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Exception[/SIZE]
[SIZE=2]MsgBox([/SIZE][SIZE=2][COLOR=#800000]"You must enter an interest amount in order for calculations to be valid."[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Try[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Loop[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Do[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]While[/COLOR][/SIZE][SIZE=2] dailyinterest = 0 [/SIZE][SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][SIZE=2] Str(dailyinterest) = [/SIZE][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] dailyinterest = 0 [/SIZE][SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][SIZE=2] Str(dailyinterest) = [/SIZE][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Try[/COLOR][/SIZE]
[SIZE=2]dailyinterest = InputBox([/SIZE][SIZE=2][COLOR=#800000]"Please Calculate and Enter the Interest Accrued on a Daily Basis"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]Catch[/COLOR][/SIZE][SIZE=2] ex2 [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Exception[/SIZE]
[SIZE=2]MsgBox([/SIZE][SIZE=2][COLOR=#800000]"You must enter a daily interest amount in order for the calculations to be valid."[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Try[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Return[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Loop[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Do[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]While[/COLOR][/SIZE][SIZE=2] interestperiod = 0 [/SIZE][SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][SIZE=2] Str(interestperiod) = [/SIZE][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] interestperiod = 0 [/SIZE][SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][SIZE=2] Str(interestperiod) = [/SIZE][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Try[/COLOR][/SIZE]
[SIZE=2]interestperiod = InputBox([/SIZE][SIZE=2][COLOR=#800000]"Please Define the Current Interest Period"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]ComboBox2.Text = interestperiod[/SIZE]
[SIZE=2][COLOR=#0000ff]Catch[/COLOR][/SIZE][SIZE=2] ex3 [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Exception[/SIZE]
[SIZE=2]MsgBox([/SIZE][SIZE=2][COLOR=#800000]"Please Define the Current Interest Period"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Try[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Return[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Loop[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Return[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Try[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Return[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] numofdays > 0 [/SIZE][SIZE=2][COLOR=#0000ff]And[/COLOR][/SIZE][SIZE=2] CheckBox1.Checked = [/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]dailyinterest = dailyinterest * numofdays[/SIZE]
[SIZE=2]penalty = totaltax * 0.1[/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] penalty < 50 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]penalty = 50[/SIZE]
[SIZE=2][COLOR=#008000]'Return[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE]
[SIZE=2]dailyinterest = 0[/SIZE]
[SIZE=2]penalty = 0[/SIZE]
[SIZE=2][COLOR=#008000]'Return[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
 
 
[SIZE=2]TextBox23.Text = dailyinterest [/SIZE][SIZE=2][COLOR=#008000]'temporary textbox to display the current daily interest %[/COLOR][/SIZE]
[SIZE=2]TextBox22.Text = [/SIZE][SIZE=2][COLOR=#0000ff]Decimal[/COLOR][/SIZE][SIZE=2].Round(interest, 2) [/SIZE][SIZE=2][COLOR=#008000]'temporary textbox to display the current interest %[/COLOR][/SIZE]
[SIZE=2]penalty = penalty + Val(previouspenaltylabel.Text)[/SIZE]
[SIZE=2]penalty = [/SIZE][SIZE=2][COLOR=#0000ff]Decimal[/COLOR][/SIZE][SIZE=2].Round(penalty, 2)[/SIZE]
[SIZE=2]duepenaltylabel.Text = penalty[/SIZE]
 
[SIZE=2]differencepenaltylabel.Text = Val(penaltytxt.Text) - penalty [/SIZE][SIZE=2][COLOR=#008000]'CType(previouspenaltylabel.Text, Decimal)[/COLOR][/SIZE]
[SIZE=2]auditpenaltylabel.Text = Val(duepenaltylabel.Text) [/SIZE][SIZE=2][COLOR=#008000]'Decimal.Round(penalty - CType(previouspenaltylabel.Text, Decimal), 2)[/COLOR][/SIZE]
 
 
[SIZE=2]totalpaid = Val(checkamttxt.Text)[/SIZE]
[SIZE=2]totaldue = [/SIZE][SIZE=2][COLOR=#0000ff]Decimal[/COLOR][/SIZE][SIZE=2].Round(totaltax + penalty + collectionallowance - [/SIZE][SIZE=2][COLOR=#0000ff]CType[/COLOR][/SIZE][SIZE=2](previousamountduelabel.Text, [/SIZE][SIZE=2][COLOR=#0000ff]Decimal[/COLOR][/SIZE][SIZE=2]), 2) [/SIZE][SIZE=2][COLOR=#008000]' ""[/COLOR][/SIZE]
 
 
 
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] CheckBox1.Checked = [/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]interestamount = (dailyinterest * totaldue) [/SIZE][SIZE=2][COLOR=#008000]'* interest[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE]
[SIZE=2]interestamount = 0 [/SIZE][SIZE=2][COLOR=#008000]'(interest * totaldue)[/COLOR][/SIZE]
[SIZE=2]penalty = 0[/SIZE]
[SIZE=2]duepenaltylabel.Text = 0.0[/SIZE]
[SIZE=2]differencepenaltylabel.Text = Val(penaltytxt.Text) - penalty[/SIZE]
[SIZE=2]flag = [/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Return[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
 
[SIZE=2]dueinterestlabel.Text = [/SIZE][SIZE=2][COLOR=#0000ff]Decimal[/COLOR][/SIZE][SIZE=2].Round(interestamount - [/SIZE][SIZE=2][COLOR=#0000ff]CType[/COLOR][/SIZE][SIZE=2](previousinterestlabel.Text, [/SIZE][SIZE=2][COLOR=#0000ff]Decimal[/COLOR][/SIZE][SIZE=2]), 2)[/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] Val(dueinterestlabel.Text) < 0 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] difference1 [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Decimal[/COLOR][/SIZE]
[SIZE=2]difference1 = Val(interesttxt.Text) + [/SIZE][SIZE=2][COLOR=#0000ff]CType[/COLOR][/SIZE][SIZE=2](dueinterestlabel.Text, [/SIZE][SIZE=2][COLOR=#0000ff]Decimal[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]differenceinterestlabel.Text = [/SIZE][SIZE=2][COLOR=#0000ff]Decimal[/COLOR][/SIZE][SIZE=2].Round(difference1, 2)[/SIZE]
[SIZE=2]auditinterestlabel.Text = Val(dueinterestlabel.Text)[/SIZE]
[SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] difference1 [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Decimal[/COLOR][/SIZE]
[SIZE=2]difference1 = Val(interesttxt.Text) - [/SIZE][SIZE=2][COLOR=#0000ff]CType[/COLOR][/SIZE][SIZE=2](dueinterestlabel.Text, [/SIZE][SIZE=2][COLOR=#0000ff]Decimal[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]differenceinterestlabel.Text = [/SIZE][SIZE=2][COLOR=#0000ff]Decimal[/COLOR][/SIZE][SIZE=2].Round(difference1, 2)[/SIZE]
[SIZE=2]auditinterestlabel.Text = Val(dueinterestlabel.Text)[/SIZE]
[SIZE=2][COLOR=#008000]'Return[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
 
 
[SIZE=2]totalwithinterest = interestamount + totaldue[/SIZE]
[SIZE=2]amountduetxt.Text = [/SIZE][SIZE=2][COLOR=#0000ff]Decimal[/COLOR][/SIZE][SIZE=2].Round(totalwithinterest, 2)[/SIZE]
[SIZE=2]returnbalance = totalwithinterest - totalpaid[/SIZE]
 
 
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] totalpaid > totaldue [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE][SIZE=2][COLOR=#008000]'this if statement is to make sure that reimbursements show up as positive and insufficient payments show up as negative[/COLOR][/SIZE]
[SIZE=2]returnbalance = -(returnbalance)[/SIZE]
[SIZE=2][COLOR=#0000ff]ElseIf[/COLOR][/SIZE][SIZE=2] totalpaid < totaldue [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]returnbalance = -(returnbalance)[/SIZE]
[SIZE=2][COLOR=#008000]'Return[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
 
 
[SIZE=2]totalpaidtxt.Text = [/SIZE][SIZE=2][COLOR=#0000ff]Decimal[/COLOR][/SIZE][SIZE=2].Round(totalpaid, 2)[/SIZE]
 
 
[SIZE=2][COLOR=#008000]'need conditional IF statement to take the return balance from the account balance when the return has a negative balance and the account has a positive balance[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'also need to use a select case statement in order to cut down on process time[/COLOR][/SIZE]
[SIZE=2]returnbaltxt.Text = [/SIZE][SIZE=2][COLOR=#0000ff]Decimal[/COLOR][/SIZE][SIZE=2].Round(returnbalance, 2)[/SIZE]
[SIZE=2]auditreturnbalancelabel.Text = Val(returnbaltxt.Text)[/SIZE]
[SIZE=2]accountbaltxt.Text = [/SIZE][SIZE=2][COLOR=#0000ff]Decimal[/COLOR][/SIZE][SIZE=2].Round(returnbalance, 2) [/SIZE][SIZE=2][COLOR=#008000]'Decimal.Round(Val(Label36.Text) + Val(Label39.Text) + Val(Label42.Text) + Val(Label46.Text) + Val(Label50.Text) + Val(Label54.Text) + Val(Label58.Text) + Val(Label62.Text), 2)[/COLOR][/SIZE]
 
 
[SIZE=2]duetaxablelabel.Text = [/SIZE][SIZE=2][COLOR=#0000ff]Decimal[/COLOR][/SIZE][SIZE=2].Round(taxablereceipts, 2)[/SIZE]
[SIZE=2]dueb4adjustlabel.Text = [/SIZE][SIZE=2][COLOR=#0000ff]Decimal[/COLOR][/SIZE][SIZE=2].Round(taxb4adjust, 2)[/SIZE]
[SIZE=2]duetotalduelabel.Text = [/SIZE][SIZE=2][COLOR=#0000ff]Decimal[/COLOR][/SIZE][SIZE=2].Round(totaltax, 2)[/SIZE]
[SIZE=2]differenceamountduelabel.Text = totalpaid - totalwithinterest [/SIZE][SIZE=2][COLOR=#008000]'Decimal.Round(returnbalances, 2) ' here is the reason I am getting the wrong values in the table.[/COLOR][/SIZE]
[SIZE=2]dueamountduelabel.Text = [/SIZE][SIZE=2][COLOR=#0000ff]Decimal[/COLOR][/SIZE][SIZE=2].Round(totaldue + interestamount, 2)[/SIZE]
[SIZE=2]auditamountduelabel.Text = Val(dueamountduelabel.Text)[/SIZE]
 
Aye carumba! What on earth is that? :D

Return is used to exit the sub or function that youre currently in. Typically you would use it if you do not want to carry on doing stuff after you find something wrong. That's why I put it in both my If statements - it didnt seem to make sense to me to allow the code to carry on if the user hadnt typed anything in a mandatory box..

It's not necessary to put Return inside an If statement as its nothing to do with the if statement.. I guess if you peppered yourprogram with returns then yup, you would get rpoblems in the same way that strewing Application.Exit(0) around would kinda tend to make your app quit a lot...
 
Back
Top