J
JP Ogden
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.LocalMachine,
"SOFTWARE\LBS\", "quickbookspath")
qbooksfile = check.GetRegValue(Microsoft.Win32.RegistryHive.LocalMachine,
"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).ToShortDateString)
orinvoiceLineAdd = invoiceAdd.ORinvoiceLineAddList.Append.invoiceLineAdd
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
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.LocalMachine,
"SOFTWARE\LBS\", "quickbookspath")
qbooksfile = check.GetRegValue(Microsoft.Win32.RegistryHive.LocalMachine,
"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).ToShortDateString)
orinvoiceLineAdd = invoiceAdd.ORinvoiceLineAddList.Append.invoiceLineAdd
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