Click here to Skip to main content
14,659,434 members
Home » Discussions » Visual Basic
   

Visual Basic

 
GeneralRe: Visual Basic "originated from an internet" EXCEL Pin
Richard MacCutchan7-Apr-20 7:59
mveRichard MacCutchan7-Apr-20 7:59 
GeneralRe: Visual Basic "originated from an internet" EXCEL Pin
raeyoung7-Apr-20 8:07
Memberraeyoung7-Apr-20 8:07 
GeneralRe: Visual Basic "originated from an internet" EXCEL Pin
Richard MacCutchan7-Apr-20 9:12
mveRichard MacCutchan7-Apr-20 9:12 
AnswerRe: Visual Basic "originated from an internet" EXCEL Pin
Mycroft Holmes7-Apr-20 11:15
professionalMycroft Holmes7-Apr-20 11:15 
QuestionInstall a VB Net application to install a sql database on other computers Pin
Member 147798703-Apr-20 12:41
MemberMember 147798703-Apr-20 12:41 
AnswerRe: Install a VB Net application to install a sql database on other computers Pin
Dave Kreskowiak3-Apr-20 14:12
mveDave Kreskowiak3-Apr-20 14:12 
AnswerRe: Install a VB Net application to install a sql database on other computers Pin
evry1falls6-May-20 9:22
Memberevry1falls6-May-20 9:22 
QuestionLinq GroupBy Invoice Number, iterate all items before group Pin
jkirkerx3-Apr-20 7:48
professionaljkirkerx3-Apr-20 7:48 
I feel like I painted myself into a corner here. But hopeful Linq was well designed to pull this off. I don't even know what to call it to look it up on the internet.

So I have a List of Items sold for the year, and each item has a cost, price, qty, invoice number, shipdate.
My objective is to group those items by invoice number. But as I group, I need to do the following ...

Say invoice 1000 has 5 items for example.
For each item assigned to invoice 1000,
I need ....
FExtCost = (FSHIPQTY * FCOST)<br />
fExtPrice = (FSHIPQTY * FPRICE)

What I have so far is the remnants of my design mistake, when I realized my numbers were wrong after fact checking the report. Like I just need the first instance of the inv number, first instance of a item description, but to total the cost, price so I can calculate the margin of the invoice.

Yes I'm asking for help writing code. Or a link to some examples I can study.
Dim gInvoicesAll As List(Of MarginCustomerInvoicesR1) = cTpAll.OrderBy(Function(ob) ob.FINVNO).GroupBy(Function(inv) inv.FINVNO).Select(Function(cl) New MarginCustomerInvoicesR1() With {
    .FCustNo = cl.First().FCUSTNO,
    .FInvNo = cl.First().FINVNO,
    .FShipDate = cl.First().FSHIPDATE,
    .FDescript = cl.First().FDESCRIPT,    
    .FAmount = cl.Sum(Function(priceTotal) priceTotal.FAMOUNT),
    .FExtCost = 0,
    .FExtPrice = 0,
    .FExtMargin = 0,
    .FPercent = 0
}).ToList()

Along time ago, Richard gave me a sophistacated solution for price, so I tried to build on it
.FPriceMin = cl.OrderByDescending(Function(i) If(i.FPrice = 0, 0, 1)).ThenByDescending(Function(i) i.FShipDate).First().FPrice,
If it ain't broke don't fix it
Discover my world at jkirkerx.com


modified 3-Apr-20 14:21pm.

AnswerRe: Linq GroupBy Invoice Number, iterate all items before group Pin
jkirkerx3-Apr-20 8:51
professionaljkirkerx3-Apr-20 8:51 
GeneralRe: Linq GroupBy Invoice Number, iterate all items before group Pin
Richard Deeming6-Apr-20 1:19
mveRichard Deeming6-Apr-20 1:19 
GeneralRe: Linq GroupBy Invoice Number, iterate all items before group Pin
jkirkerx6-Apr-20 7:28
professionaljkirkerx6-Apr-20 7:28 
GeneralRe: Linq GroupBy Invoice Number, iterate all items before group Pin
Richard Deeming6-Apr-20 8:01
mveRichard Deeming6-Apr-20 8:01 
GeneralRe: Linq GroupBy Invoice Number, iterate all items before group Pin
jkirkerx6-Apr-20 9:20
professionaljkirkerx6-Apr-20 9:20 
GeneralRe: Linq GroupBy Invoice Number, iterate all items before group Pin
Richard Deeming7-Apr-20 0:30
mveRichard Deeming7-Apr-20 0:30 
GeneralRe: Linq GroupBy Invoice Number, iterate all items before group Pin
jkirkerx7-Apr-20 7:05
professionaljkirkerx7-Apr-20 7:05 
GeneralRe: Linq GroupBy Invoice Number, iterate all items before group Pin
jkirkerx8-Apr-20 9:24
professionaljkirkerx8-Apr-20 9:24 
QuestionHow to update sql server data from excel data using VBA code by all User Pin
Member 1478441627-Mar-20 0:25
MemberMember 1478441627-Mar-20 0:25 
AnswerRe: How to update sql server data from excel data using VBA code by all User Pin
ZurdoDev27-Mar-20 1:19
mveZurdoDev27-Mar-20 1:19 
GeneralRe: How to update sql server data from excel data using VBA code by all User Pin
Member 1478441627-Mar-20 2:17
MemberMember 1478441627-Mar-20 2:17 
AnswerMessage Closed Pin
13-Apr-20 2:16
MemberSharie14d13-Apr-20 2:16 
Questionevent handler Pin
Member 1356965021-Mar-20 23:16
MemberMember 1356965021-Mar-20 23:16 
AnswerRe: event handler Pin
Richard MacCutchan21-Mar-20 23:31
mveRichard MacCutchan21-Mar-20 23:31 
GeneralRe: event handler Pin
Member 1356965022-Mar-20 0:24
MemberMember 1356965022-Mar-20 0:24 
GeneralRe: event handler Pin
Richard MacCutchan22-Mar-20 0:33
mveRichard MacCutchan22-Mar-20 0:33 
GeneralRe: event handler Pin
Member 1356965022-Mar-20 1:04
MemberMember 1356965022-Mar-20 1:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.