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
Visual Basic.NET

Avatar of undefined
Last Comment
avi4

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
YZlat

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
avi4

ASKER
Thanks!
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck