470,810 Members | 1,251 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,810 developers. It's quick & easy.

Translate .NET code to VBA

I have a some .NET code that I need to translate into VB. Does anyone know
how
to do this? If so, thanks in advance!

Here is the code. I only need the translation code between START
TRANSLATION HERE and
END TRANSLATION HERE translated.

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim requestMsgSet As QBFC4Lib.IMsgSetRequest
Dim sessionmgr As QBSessionManager
Dim check As New RegistryReadEntry
sessionmgr = New QBSessionManager
sessionmgr.OpenConnection("", "Test Stuff")
qbookspath = check.GetRegValue(Microsoft.Win32.RegistryHive.Loc alMachine,
"SOFTWARE\LBS\", "quickbookspath")
qbooksfile = check.GetRegValue(Microsoft.Win32.RegistryHive.Loc alMachine,
"SOFTWARE\LBS\", "quickbooksfilename")
'sessionmgr.BeginSession(qbookspath & "\" & qbooksfile,
ENOpenMode.omDontCare)
sessionmgr.BeginSession("C:\Program Files\Intuit\QuickBooks Basic" & "\" &
"sample_product-based business.qbw", ENOpenMode.omDontCare)

Try
requestMsgSet = sessionmgr.CreateMsgSetRequest("US", "2", "0")
requestMsgSet.Attributes.OnError = QBFC4Lib.ENRqOnError.roeStop

Dim invoiceAdd As QBFC4Lib.IinvoiceAdd
invoiceAdd = requestMsgSet.AppendinvoiceAddRq

'START TRANSLATION HERE -
Dim sqlquery As String
Dim ds As DataSet
Dim item, desc, listid, weight, count, lastid As String
Dim records, i As Integer
sqlquery = "SELECT DISTINCTROW category.item, category.desc, Customers.acct,
Customers.CustomerName, Customers.listid, transactions.acct,
transactions.item, Sum(transactions.weight) AS [Sum Of weight], Count(*) AS
[Count Of category]"
sqlquery = sqlquery & " FROM Customers INNER JOIN (category INNER JOIN
transactions ON category.item = transactions.item) ON Customers.acct =
transactions.acct"
sqlquery = sqlquery & " GROUP BY category.item, category.desc,
Customers.acct, Customers.CustomerName, Customers.listid, transactions.acct,
transactions.item;"
ds = openDataSet(sqlquery)
records = ds.Tables(0).Rows.Count
If records < 0 Then
MsgBox("No records to Invioce", MsgBoxStyle.OKOnly, "invoice Error")
lastid = ""
Else
count = 0
For i = 0 To records - 1
item = ds.Tables(0).Rows(i)("item")
desc = ds.Tables(0).Rows(i)("desc")
listid = ds.Tables(0).Rows(i)("listid")
count = ds.Tables(0).Rows(i)("count of category")
weight = ds.Tables(0).Rows(i)("sum of weight")
Dim orinvoiceLineAdd As IinvoiceLineAdd
invoiceAdd.CustomerRef.ListID.SetValue(listid)
invoiceAdd.IsToBePrinted.SetValue(True)
invoiceAdd.TxnDate.SetValue(CDate(Now).ToShortDate String)

orinvoiceLineAdd = invoiceAdd.ORinvoiceLineAddList.Append.invoiceLine Add

orinvoiceLineAdd.ItemRef.FullName.SetValue(item)
orinvoiceLineAdd.Desc.SetValue(desc & " Number of Bins " & count)
orinvoiceLineAdd.Quantity.SetValue(weight)
If records - 1 <> i Then
lastid = ds.Tables(0).Rows(i + 1)("listid")
End If
If lastid <> listid Or i = records - 1 Then

'END TRANSLATION HERE

sessionmgr.DoRequests(requestMsgSet)
requestMsgSet = Nothing
requestMsgSet = sessionmgr.CreateMsgSetRequest("US", "2", "0")
requestMsgSet.Attributes.OnError = QBFC4Lib.ENRqOnError.roeStop
invoiceAdd = requestMsgSet.AppendinvoiceAddRq
End If

Next

End If
Yes People I figured it out. It may not be the best way ot do it but it
works. Please to whomever is out there put some usable samples out there
like the basics of adding an invoice etc...All the samples out there kind of
skate around teh 700lb gorilla in the room which is to CREATE invoiceS

Catch ex As Exception
MsgBox(ex.Source & ":" & ex.Message)
Finally

End Try
MsgBox("invoice Added")
sessionmgr.EndSession()
sessionmgr.CloseConnection()
sessionmgr = Nothing
End Sub

Feb 9 '06 #1
2 2722
JP,

You cannot, VBA cannot use ADO.NET what is the part you showed almost
completely.
(There is even a part probably in a dataacceslayer .... ds =
openDataSet(sqlquery))

You will have to use

ADODB what is completely different (other search item MDAC).

http://msdn.microsoft.com/SQL/2000/l...c/default.aspx

http://msdn.microsoft.com/data/mdac/...o/default.aspx

I hope this helps,

Cor
"JP Ogden" <jp*****@earthlink.net> schreef in bericht
news:Oo**************@TK2MSFTNGP11.phx.gbl...
I have a some .NET code that I need to translate into VB. Does anyone know
how
to do this? If so, thanks in advance!

Here is the code. I only need the translation code between START
TRANSLATION HERE and
END TRANSLATION HERE translated.

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim requestMsgSet As QBFC4Lib.IMsgSetRequest
Dim sessionmgr As QBSessionManager
Dim check As New RegistryReadEntry
sessionmgr = New QBSessionManager
sessionmgr.OpenConnection("", "Test Stuff")
qbookspath = check.GetRegValue(Microsoft.Win32.RegistryHive.Loc alMachine,
"SOFTWARE\LBS\", "quickbookspath")
qbooksfile = check.GetRegValue(Microsoft.Win32.RegistryHive.Loc alMachine,
"SOFTWARE\LBS\", "quickbooksfilename")
'sessionmgr.BeginSession(qbookspath & "\" & qbooksfile,
ENOpenMode.omDontCare)
sessionmgr.BeginSession("C:\Program Files\Intuit\QuickBooks Basic" & "\" &
"sample_product-based business.qbw", ENOpenMode.omDontCare)

Try
requestMsgSet = sessionmgr.CreateMsgSetRequest("US", "2", "0")
requestMsgSet.Attributes.OnError = QBFC4Lib.ENRqOnError.roeStop

Dim invoiceAdd As QBFC4Lib.IinvoiceAdd
invoiceAdd = requestMsgSet.AppendinvoiceAddRq

'START TRANSLATION HERE -
Dim sqlquery As String
Dim ds As DataSet
Dim item, desc, listid, weight, count, lastid As String
Dim records, i As Integer
sqlquery = "SELECT DISTINCTROW category.item, category.desc,
Customers.acct,
Customers.CustomerName, Customers.listid, transactions.acct,
transactions.item, Sum(transactions.weight) AS [Sum Of weight], Count(*)
AS
[Count Of category]"
sqlquery = sqlquery & " FROM Customers INNER JOIN (category INNER JOIN
transactions ON category.item = transactions.item) ON Customers.acct =
transactions.acct"
sqlquery = sqlquery & " GROUP BY category.item, category.desc,
Customers.acct, Customers.CustomerName, Customers.listid,
transactions.acct,
transactions.item;"
ds = openDataSet(sqlquery)
records = ds.Tables(0).Rows.Count
If records < 0 Then
MsgBox("No records to Invioce", MsgBoxStyle.OKOnly, "invoice Error")
lastid = ""
Else
count = 0
For i = 0 To records - 1
item = ds.Tables(0).Rows(i)("item")
desc = ds.Tables(0).Rows(i)("desc")
listid = ds.Tables(0).Rows(i)("listid")
count = ds.Tables(0).Rows(i)("count of category")
weight = ds.Tables(0).Rows(i)("sum of weight")
Dim orinvoiceLineAdd As IinvoiceLineAdd
invoiceAdd.CustomerRef.ListID.SetValue(listid)
invoiceAdd.IsToBePrinted.SetValue(True)
invoiceAdd.TxnDate.SetValue(CDate(Now).ToShortDate String)

orinvoiceLineAdd = invoiceAdd.ORinvoiceLineAddList.Append.invoiceLine Add

orinvoiceLineAdd.ItemRef.FullName.SetValue(item)
orinvoiceLineAdd.Desc.SetValue(desc & " Number of Bins " & count)
orinvoiceLineAdd.Quantity.SetValue(weight)
If records - 1 <> i Then
lastid = ds.Tables(0).Rows(i + 1)("listid")
End If
If lastid <> listid Or i = records - 1 Then

'END TRANSLATION HERE

sessionmgr.DoRequests(requestMsgSet)
requestMsgSet = Nothing
requestMsgSet = sessionmgr.CreateMsgSetRequest("US", "2", "0")
requestMsgSet.Attributes.OnError = QBFC4Lib.ENRqOnError.roeStop
invoiceAdd = requestMsgSet.AppendinvoiceAddRq
End If

Next

End If
Yes People I figured it out. It may not be the best way ot do it but it
works. Please to whomever is out there put some usable samples out there
like the basics of adding an invoice etc...All the samples out there kind
of
skate around teh 700lb gorilla in the room which is to CREATE invoiceS

Catch ex As Exception
MsgBox(ex.Source & ":" & ex.Message)
Finally

End Try
MsgBox("invoice Added")
sessionmgr.EndSession()
sessionmgr.CloseConnection()
sessionmgr = Nothing
End Sub


Feb 9 '06 #2
JP,

Maybe can this one help you, although it is the other way around.

http://msdn.microsoft.com/library/de...chitecture.asp

I hope this helps,

Cor
Feb 9 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Xeon | last post: by
7 posts views Thread by Johnny Lee | last post: by
6 posts views Thread by VBTricks.de.vu Webmaster | last post: by
6 posts views Thread by bobueland | last post: by
1 post views Thread by peterbe | last post: by
bvdet
9 posts views Thread by bvdet | last post: by
4 posts views Thread by kovariadam | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.