torg Posted April 15, 2003 Posted April 15, 2003 I`ve got lstAmount. I whish to show the sum as a currencyformat in the listbox. How do I do that? adInCome = New OleDb.OleDbDataAdapter("SELECT sum(tblIncome.Amount) as Total from tblIncome ;", Me.OleDbConnection) Try adInCome .Fill(dsIncome, "dtInncome") Catch ex As OleDb.OleDbException MessageBox.Show(ex.Message) End Try Me.OleDbConnection.Close() lstAmount.DataSource = dsIncome.Tables("dtIncome") lstAmount.ValueMember = "Total" Quote
*Experts* Nerseus Posted April 15, 2003 *Experts* Posted April 15, 2003 I don't know if there's a built-in way to do it. You can loop through the DataTable and add each item, of course, and format each Total as currency as you go (use the ToString("c") method). -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
torg Posted April 15, 2003 Author Posted April 15, 2003 Thank You. I used this code to achieve what I wanted to achieve Dim DataView1 As DataView = New DataView() With DataView1 .Table = dsUtgiftspost.Tables("dtUtgiftspost") End With Dim drv As DataRowView Dim s As String = "" For Each drv In DataView1 s &= drv("Total").ToString & " " Next lstBelop.Items.Add(FormatCurrency(s)) '<< Sets the currency format Quote
*Experts* Nerseus Posted April 15, 2003 *Experts* Posted April 15, 2003 If you don't need the DataView for anything else I wouldn't use it. Also, don't you want each item to be a separate string? Try something like this: Dim dr As DataRow For Each dr In dsUtgiftspost.Tables("dtUtgiftspost").Rows lstBelop.Items.Add(dr("Total").ToString("c")) Next -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.