Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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"

  • *Experts*
Posted

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

"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
Posted

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

  • *Experts*
Posted

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

"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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...