Strange XML TextWriter issue

Bilalq

Member
Joined
Jul 21, 2004
Messages
24
Programming Experience
3-5
Hello,
I am using XMLTextWriter class to create XML files. It is working great, but I seem to have one problem that can't figure out.
The project calls for creating different files based on customer data. Individually they work fine, but when I put them in a loop, the first file is generated just fine, the second file would contain data from the first and the second and the third one from first, second and third. Not sure what is happeing. I am flushing the stream and closing it and destrying the object. Plus, I also several different things, but can't figure it out. Can some on eplease let me know what I am missing.
Thanks in advance.


Here is an example of what it should be.......
File 1
Customer 1 data
File 2
Customer 2 Data
File 3
Customer 3 Data

AND HERE IS HOW IT IS COMING RIGHT NOW AND IT IS INCORRECT

File 1
Customer 1 Data
File 2
Customer 1 Data
Customer 2 Data
File 3
Customer 1 Data
Customer 2 Data
Customer 3 Data
 
If you can post the loop you are using we can take a look. From what it looks like you need to add a condition to the loop to only add data to the appropriate file, without seeing how you are doing it, it is difficult to advise.
 
Thanks for the reply, here is the code, it is rather large. The sub in the code is responsible for generating the xml file. It is being called in a loop.

VB.NET:
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2][COLOR=#800000] Generate_XML([/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2][COLOR=#800000] strFileName [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000], _[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2][COLOR=#800000] strFilePath [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000], _[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2][COLOR=#800000] ReturnInfo [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#800000] BCC.ElectronicStateReturnsCollection)[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2][COLOR=#800000] blnOverPayment [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Boolean[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2][COLOR=#800000] strDueDate [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000] = [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000].Empty[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2][COLOR=#800000] strFEIN [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000] = [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000].Empty[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2][COLOR=#800000] strEIN [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000] = [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000].Empty[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2][COLOR=#800000] strBusinessName [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000] = [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000].Empty[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2][COLOR=#800000] strPreparerName [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000] = [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000].Empty[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2][COLOR=#800000] strPreparerSSN [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000] = [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000].Empty[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2][COLOR=#800000] strPhone [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000] = [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000].Empty[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2][COLOR=#800000] strEmailAddress [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000] = [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000].Empty[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2][COLOR=#800000] strTitle [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000] = [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000].Empty[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2][COLOR=#800000] strSignature [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000] = [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000].Empty[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2][COLOR=#800000] strFax [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000] = [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000].Empty[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2][COLOR=#800000] strTaxYear [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000] = [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000].Empty[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2][COLOR=#800000] strFinalReturnElect [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000] = [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000].Empty[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2][COLOR=#800000] strAttrib15 [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000] = [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000].Empty[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2][COLOR=#800000] strAttrib1131 [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000] = [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000].Empty[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2][COLOR=#800000] intNumberOfRecords [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2][COLOR=#800000] dblYearWages [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Double[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2][COLOR=#800000] dblIncometaxWithheld [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Double[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2][COLOR=#800000] dblWhBalanceDue [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Double[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2][COLOR=#800000] dblAmountofOverPayment [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Double[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2][COLOR=#800000] strRefundElect [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000] = [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#800000].Empty[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2][COLOR=#800000] dblLiabilityPeriodAmt [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Double[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2][COLOR=#800000] dblAmtWithheldQ1 [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Double[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2][COLOR=#800000] dblAmtWithheldQ2 [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Double[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2][COLOR=#800000] dblAmtWithheldQ3 [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Double[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2][COLOR=#800000] dblAmtWithheldQ4 [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Double[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2][COLOR=#800000] strTemp [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2][COLOR=#800000] strCurrentFileName [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2][COLOR=#800000] xmlFile [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2][COLOR=#800000] xmlWriter [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#800000] XmlTextWriter[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Try[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2][COLOR=#800000] i [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2][COLOR=#800000] = 0 [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2][COLOR=#800000] ReturnInfo.Count - 1[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Select[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]CInt[/COLOR][/SIZE][SIZE=2][COLOR=#800000](ReturnInfo.Item(i).attributeCode)[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000] RET_ATTRIB_DUE_DATE[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strDueDate = ReturnInfo.Item(i).fieldValue.Trim[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000] RET_ATRRIB_FEIN[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strTemp = ReturnInfo.Item(i).fieldValue.Trim[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2][COLOR=#800000] strTemp <> "" [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strFEIN = strTemp.Replace("-", "").Replace(" ", "")[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strFEIN = ""[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000] RET_ATTRIB_EIN[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strTemp = ReturnInfo.Item(i).fieldValue.Trim[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2][COLOR=#800000] strTemp <> "" [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strEIN = strTemp.Replace(" ", "-")[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strEIN = ""[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000] RET_ATTRIB_BUSINESS_NAME[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strTemp = ReturnInfo.Item(i).fieldValue.Trim[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2][COLOR=#800000] strTemp.Length > 30 [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strTemp = strTemp.Substring(0, 30)[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strBusinessName = strTemp[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000] RET_ATTRIB_PREPARER_NAME[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strTemp = ReturnInfo.Item(i).fieldValue.Trim[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2][COLOR=#800000] strTemp.Length > 35 [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strTemp = strTemp.Substring(0, 35)[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strPreparerName = strTemp[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000] RET_ATTRIB_PREPARER_SSN[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strTemp = ReturnInfo.Item(i).fieldValue.Trim[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2][COLOR=#800000] strTemp <> "" [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strPreparerSSN = strTemp.Replace("-", "")[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strPreparerSSN = ""[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000] RET_ATTRIB_PHONE[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strTemp = ReturnInfo.Item(i).fieldValue.Trim[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2][COLOR=#800000] strTemp <> "" [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strPhone = strTemp.Replace("-", "").Replace("(", "").Replace(")", "")[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strPhone = ""[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000] RET_ATTRIB_EMAIL_ADDRESS[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strTemp = ReturnInfo.Item(i).fieldValue.Trim[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2][COLOR=#800000] strTemp.Length > 75 [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strTemp = strTemp.Substring(0, 75)[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strEmailAddress = strTemp[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000] RET_ATTRIB_TITLE[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strTemp = ReturnInfo.Item(i).fieldValue.Trim[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2][COLOR=#800000] strTemp.Length > 35 [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strTemp = strTemp.Substring(0, 35)[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strTitle = strTemp[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000] RET_ATTRIB_SIGNATURE[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strSignature = ReturnInfo.Item(i).fieldValue.Trim[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000] RET_ATTRIB_FAX[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strFax = ReturnInfo.Item(i).fieldValue.Trim[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000] RET_ATTRIB_TAX_YEAR[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strTaxYear = ReturnInfo.Item(i).fieldValue.Trim[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000] RET_ATTRIB_FINAL_RETURN_ELECT[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strFinalReturnElect = ReturnInfo.Item(i).fieldValue.Trim[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000] RET_ATTRIB_15[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strAttrib15 = ReturnInfo.Item(i).fieldValue.Trim[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000] RET_ATTRIB_1131[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strAttrib1131 = ReturnInfo.Item(i).fieldValue.Trim[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000] RET_ATTRIB_NUMOFRECS[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]intNumberOfRecords = [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]CInt[/COLOR][/SIZE][SIZE=2][COLOR=#800000](DblIfEmpty(ReturnInfo.Item(i).fieldValue.Trim, 0))[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000] RET_ATTRIB_YEAR_WAGES[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]dblYearWages = DblIfEmpty(ReturnInfo.Item(i).fieldValue.Trim, 0)[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000] RET_ATTRIB_INCOME_TAX_WITHHELD[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]dblIncometaxWithheld = DblIfEmpty(ReturnInfo.Item(i).fieldValue.Trim, 0)[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000] RET_ATTRIB_WH_BALANACE_DUE[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]dblWhBalanceDue = dblifempty(ReturnInfo.Item(i).fieldValue.Trim, 0)[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000] RET_ATTRIB_AMT_OVERPAYMENT[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]dblAmountofOverPayment = DblIfEmpty(ReturnInfo.Item(i).fieldValue.Trim, 0)[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000] RET_ATTRIB_LIABILITY_PERIOD_AMT[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]dblLiabilityPeriodAmt = DblIfEmpty(ReturnInfo.Item(i).fieldValue.Trim, 0)[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000] RET_ATTRIB_AMT_WITHHELD_Q1[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]dblAmtWithheldQ1 = DblIfEmpty(ReturnInfo.Item(i).fieldValue.Trim, 0)[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000] RET_ATTRIB_AMT_WITHHELD_Q2[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]dblAmtWithheldQ2 = DblIfEmpty(ReturnInfo.Item(i).fieldValue.Trim, 0)[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000] RET_ATTRIB_AMT_WITHHELD_Q3[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]dblAmtWithheldQ3 = DblIfEmpty(ReturnInfo.Item(i).fieldValue.Trim, 0)[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000] RET_ATTRIB_AMT_WITHHELD_Q4[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]dblAmtWithheldQ4 = DblIfEmpty(ReturnInfo.Item(i).fieldValue.Trim, 0)[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Select[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'File Name should be FEIN_UserProvidedName[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strCurrentFileName = ""[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strCurrentFileName = strFEIN & "_" & strFileName[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'There should be one FEIN per file[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlFile = strFilePath & strCurrentFileName[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter = [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2][COLOR=#800000] XmlTextWriter(xmlFile, System.Text.Encoding.UTF8)[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2][COLOR=#800000] strFEINFileNames = "" [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strFEINFileNames = strCurrentFileName[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strFEINFileNames = strFEINFileNames & "," & strCurrentFileName[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.Flush()[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#008000]'set the formatiing for the xml file[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.Formatting = Formatting.Indented[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.Indentation = 4[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.IndentChar = " "c[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteStartDocument()[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Write the Root Node[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteStartElement("StateAnnual")[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'write the attribute for the file element[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteAttributeString("xmlns", "http://www.irs.gov")[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteAttributeString("xmlns:xsl", "http://www.w3.org/2001/XMLSchema-instance")[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteAttributeString("xsi:schemaLocation", "http://www.irs.gov/efile H:\FSET\FSETV02.0\STATES~1\StateAnnual.xsd")[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Write First Node (ReturnHeader)[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteStartElement("ReturnHeader")[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Timestamp[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("ElectronicPostMark", Format(Now, "yyyy-MM-ddThh:mm:ss"))[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'DueDate format YYYY-MM-DD[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2][COLOR=#800000] strDueDate <> "" [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("DueDate", Format([/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2][COLOR=#800000].Parse(strDueDate), "yyyy-MM-dd"))[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("DueDate", "")[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Software ID Always 1027[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("SoftwareId", "1027")[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'ReturnType Always "StateAnnual"[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("ReturnType", "StateAnnual")[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Filing Action Node[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteStartElement("FilingAction")[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Action always "Original[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("Action", "Original")[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Close Filing Action node[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteEndElement()[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'TIN Node[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteStartElement("TIN")[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'TIN TYPe Node Always "FEIN"[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("TypeTIN", "FEIN")[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'FEIN Value format 999999999[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("TINTypeValue", strFEIN)[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Close TIN Node[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteEndElement()[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'State EIN Node[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteStartElement("StateEIN")[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Type always "WithholdingAccountNo"[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("TypeStateEIN", "WithholdingAccountNo")[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'State EIN format 999999-9[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("StateEINValue", strEIN)[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Close State EIN[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteEndElement()[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'FIPS Code "55"[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("FIPSCode", "55")[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Business Address Node[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteStartElement("BusinessAddress")[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Business Name Size = 30[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("BusinessName", strBusinessName)[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Close Business Address Node[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteEndElement()[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Preparere Node[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteStartElement("Preparer")[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Prepare Name Size = 35[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("Name", strPreparerName)[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Preparer SSN format 999999999[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("SSN", strPreparerSSN)[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Preparer Phone format 9999999999[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("Phone", strPhone)[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Preparer Email Address Size = 75[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("EmailAddress", strEmailAddress)[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Close Preparer Node[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteEndElement()[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'ReturnSigner Node[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteStartElement("ReturnSigner")[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Name Size = 35[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("Name", strPreparerName)[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Title Size = 35[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("Title", strTitle)[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Phone format 9999999999[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("Phone", strPhone)[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Email Address Size = 75[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("EmailAddress", strEmailAddress)[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Signature format 9999999999[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("Signature", strSignature)[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Close ReturnSigner Node[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteEndElement()[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Conatact Node[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteStartElement("Contact")[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Contact Name Node[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteStartElement("ContactName")[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Title Size = 35[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("Title", strTitle)[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'FullName Size = 35[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("FullName", strPreparerName)[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Close Contact Name Node[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteEndElement()[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Phone format 9999999999[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("Phone", strPhone)[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Fax format 9999999999[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("Fax", strFax)[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Email Address Size = 75[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("EmailAddress", strEmailAddress)[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Close Conact Node[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteEndElement()[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'AckAddress (Email Address here) Size = 75[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("AckAddress", strEmailAddress)[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Close StateAnnula Node[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteEndElement()[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Tax Year format YYYY[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("TaxYear", strTaxYear)[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Final Return Elect[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("FinalReturnElect", strFinalReturnElect)[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Submit W2 Flag[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2][COLOR=#800000] strAttrib15 = "X" [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strTemp = "3"[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]ElseIf[/COLOR][/SIZE][SIZE=2][COLOR=#800000] strAttrib1131 = "X" [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strTemp = "2"[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]strTemp = "1"[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("SubmitW2", strTemp)[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Number of Records[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("NumberOfRecords", intNumberOfRecords.ToString)[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Total Wages for the year[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("TotalWagesYear", Format(dblYearWages, "##0000.00"))[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Total Income Tax Withheld[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("TotalIncomeTaxWithheld", Format(dblIncometaxWithheld, "##0000.00"))[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Following is for overpayment only[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2][COLOR=#800000] dblLiabilityPeriodAmt > dblIncometaxWithheld [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]blnOverPayment = [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Over Payment Node (If needed)[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2][COLOR=#800000] blnOverPayment [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteStartElement("WHOverpayment")[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Calculate the over payment[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]dblAmountofOverPayment = dblLiabilityPeriodAmt - dblIncometaxWithheld[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("AmountOfOverPayment", Format(dblAmountofOverPayment, "##0000.00"))[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteEndElement()[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE][SIZE=2][COLOR=#008000]'else add WHBalanceDue[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("WHBalanceDue", Format(dblWhBalanceDue, "##0000.00"))[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Liabilities PeriodAmount[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteStartElement("LiabilityPeriodAmount")[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Attribute Period always "1"[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteAttributeString("Period", "1")[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Liability Amount[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteString(Format(dblLiabilityPeriodAmt, "##0000.00"))[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteEndElement()[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Amount Withheld 1st Quarter[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("AmountWithheld1stQuarter", Format(dblAmtWithheldQ1, "##0000.00"))[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Amount Withheld 2nd Quarter[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("AmountWithheld2ndQuarter", Format(dblAmtWithheldQ2, "##0000.00"))[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Amount Withheld 3rd quarter[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("AmountWithheld3rdQuarter", Format(dblAmtWithheldQ3, "##0000.00"))[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Amount withheld 4th quarter[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteElementString("AmountWithheld4thQuarter", Format(dblAmtWithheldQ4, "##0000.00"))[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Write End of XML Document to close nodes[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.WriteEndDocument()[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'close the file[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.Flush()[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter.Close()[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Catch[/COLOR][/SIZE][SIZE=2][COLOR=#800000] ex [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#800000] Exception[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Throw[/COLOR][/SIZE][SIZE=2][COLOR=#800000] ex[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Finally[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Not[/COLOR][/SIZE][SIZE=2][COLOR=#800000] IsNothing(xmlWriter) [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]xmlWriter = [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Nothing[/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=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
 
Back
Top