avi4
asked on
How to rewrite VB code to VB.net
Hi,
Could someone please help me on how to rewrite this code in VB.NET?
Thanks in advance.
Public Function GenerateReport()
Dim sql1 As String
Dim sql2 As String
Dim sql3 As String
Dim GRrs As New ADODB.Recordset
Dim GR2rs As New ADODB.Recordset
Dim GR3rs As New ADODB.Recordset
Dim txtFile As Scripting.TextStream
Dim SOLfso1 As New FileSystemObject
Dim tempdate As String
Dim thelockbox As String
Dim UseDateX As String
thelockbox = XType
UseDateX = FormatDateTime(Now, vbShortDate)
tempdate = theDateX
sql1 = "select count(amount) as totalRecs, sum(cast(amount as money)) as totalamt " & _
"From customer" & _
"where acctnum='" & MstrAcct & "' and transstatus=1 and transdate>='" & UseDateX & "' "
sql2 = "declare @Spacer varchar(4) " & _
"select @Spacer = ' ' " & _
"select acctnum, storenbr as VisionAcct, amount, retid, returnreason, retaction, micrcheck, cast(maker1 as varchar(10)) as pmtdate, @spacer, entrydate " & _
"From customer " & _
"where acctnum='" & MstrAcct & "' and transstatus=1 and transdate>='" & UseDateX & "' "
sql3 = "select acctnum, storenbr as VisionAcct, amount, retid, returnreason, retaction, micrcheck, micracct, micrrt, maker1 as pmtdate, entrydate " & _
"From customer " & _
"where acctnum='" & MstrAcct & "' and transstatus<>1 and transdate>='" & UseDateX & "' "
Set txtFile = SOLfso1.CreateTextFile("\\ ***\***\** *\***\MyFo lder\" & thelockbox & "_DailyReport_" & tempdate & ".txt", True)
GRrs.Open sql1, VRcn
txtFile.Write ("Report." & vbCrLf)
txtFile.Write ("" & vbCrLf)
txtFile.Write ("Lockbox: " & thelockbox & vbCrLf)
txtFile.Write ("Total items submitted: " & GRrs.Fields("totalRecs").V alue & vbCrLf)
txtFile.Write ("Total amount of items submitted: " & GRrs.Fields("totalamt").Va lue & vbCrLf)
txtFile.Write ("Lockbox Acct" & vbTab & "Account No " & vbTab & "Amount" & vbTab & "Return ID" & vbTab & "Reason" & vbTab & "Action" & vbTab & "Check No" & vbTab & "Pmt Date" & vbTab & "Submission Date" & vbCrLf)
GR2rs.Open sql2, VRcn
txtFile.Write (GR2rs.GetString(adClipStr ing, , vbTab, vbCrLf, ""))
txtFile.Write ("Account that could not be submitted for automatic reversal:" & vbCrLf)
txtFile.Write ("" & vbCrLf)
GR3rs.Open sql3, VRcn
If GR3rs.EOF Or GR3rs.BOF Then
txtFile.Write ("All Accounts provided were submitted for processing." & vbCrLf)
Else
txtFile.Write ("Lockbox Acct" & vbTab & "Account No " & vbTab & "Amount" & vbTab & "Return ID" & vbTab & "Reason" & vbTab & "Action" & vbTab & "Check No" & vbTab & "Ck Acct No" & vbTab & "Ck Routing No" & vbTab & "Pmt Date" & vbTab & "Rev Submission Date" & vbCrLf)
txtFile.Write (Trim(GR3rs.GetString(adCl ipString, , vbTab, vbCrLf, "")))
End If
GR3rs.Close
GR2rs.Close
GRrs.Close
Set GRrs = Nothing
Set GR2rs = Nothing
Set GR3rs = Nothing
Exit Function
Could someone please help me on how to rewrite this code in VB.NET?
Thanks in advance.
Public Function GenerateReport()
Dim sql1 As String
Dim sql2 As String
Dim sql3 As String
Dim GRrs As New ADODB.Recordset
Dim GR2rs As New ADODB.Recordset
Dim GR3rs As New ADODB.Recordset
Dim txtFile As Scripting.TextStream
Dim SOLfso1 As New FileSystemObject
Dim tempdate As String
Dim thelockbox As String
Dim UseDateX As String
thelockbox = XType
UseDateX = FormatDateTime(Now, vbShortDate)
tempdate = theDateX
sql1 = "select count(amount) as totalRecs, sum(cast(amount as money)) as totalamt " & _
"From customer" & _
"where acctnum='" & MstrAcct & "' and transstatus=1 and transdate>='" & UseDateX & "' "
sql2 = "declare @Spacer varchar(4) " & _
"select @Spacer = ' ' " & _
"select acctnum, storenbr as VisionAcct, amount, retid, returnreason, retaction, micrcheck, cast(maker1 as varchar(10)) as pmtdate, @spacer, entrydate " & _
"From customer " & _
"where acctnum='" & MstrAcct & "' and transstatus=1 and transdate>='" & UseDateX & "' "
sql3 = "select acctnum, storenbr as VisionAcct, amount, retid, returnreason, retaction, micrcheck, micracct, micrrt, maker1 as pmtdate, entrydate " & _
"From customer " & _
"where acctnum='" & MstrAcct & "' and transstatus<>1 and transdate>='" & UseDateX & "' "
Set txtFile = SOLfso1.CreateTextFile("\\
GRrs.Open sql1, VRcn
txtFile.Write ("Report." & vbCrLf)
txtFile.Write ("" & vbCrLf)
txtFile.Write ("Lockbox: " & thelockbox & vbCrLf)
txtFile.Write ("Total items submitted: " & GRrs.Fields("totalRecs").V
txtFile.Write ("Total amount of items submitted: " & GRrs.Fields("totalamt").Va
txtFile.Write ("Lockbox Acct" & vbTab & "Account No " & vbTab & "Amount" & vbTab & "Return ID" & vbTab & "Reason" & vbTab & "Action" & vbTab & "Check No" & vbTab & "Pmt Date" & vbTab & "Submission Date" & vbCrLf)
GR2rs.Open sql2, VRcn
txtFile.Write (GR2rs.GetString(adClipStr
txtFile.Write ("Account that could not be submitted for automatic reversal:" & vbCrLf)
txtFile.Write ("" & vbCrLf)
GR3rs.Open sql3, VRcn
If GR3rs.EOF Or GR3rs.BOF Then
txtFile.Write ("All Accounts provided were submitted for processing." & vbCrLf)
Else
txtFile.Write ("Lockbox Acct" & vbTab & "Account No " & vbTab & "Amount" & vbTab & "Return ID" & vbTab & "Reason" & vbTab & "Action" & vbTab & "Check No" & vbTab & "Ck Acct No" & vbTab & "Ck Routing No" & vbTab & "Pmt Date" & vbTab & "Rev Submission Date" & vbCrLf)
txtFile.Write (Trim(GR3rs.GetString(adCl
End If
GR3rs.Close
GR2rs.Close
GRrs.Close
Set GRrs = Nothing
Set GR2rs = Nothing
Set GR3rs = Nothing
Exit Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER