Link to home
Start Free TrialLog in
Avatar of avi4
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("\\***\***\***\***\MyFolder\" & 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").Value & vbCrLf)
txtFile.Write ("Total amount of items submitted: " & GRrs.Fields("totalamt").Value & 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(adClipString, , 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(adClipString, , vbTab, vbCrLf, "")))

End If

GR3rs.Close
GR2rs.Close
GRrs.Close

Set GRrs = Nothing
Set GR2rs = Nothing
Set GR3rs = Nothing

Exit Function
ASKER CERTIFIED SOLUTION
Avatar of YZlat
YZlat
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of avi4
avi4

ASKER

Thanks!