Adding String Values

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mwcapps
    New Member
    • Mar 2009
    • 16

    Adding String Values

    I've got 2 labels (lblDSPCash and lblLCash) that are setup:

    Format(dsDSPCas h.Tables("dspca sh").Rows(0)("d spcash"), "Currency")

    and

    Format(dsLCash. Tabls("localcas h").Rows(0)("lc ash"), "Currency")

    My 3rd label (lblTCash) is supposed to be a 'sum' of the other two. I've tried the following code but it rounds to the nearest dollar:

    Dim iDCash as string
    Dim iLCash as string

    iDCash = dsDSPCash.Table s("dspcash").Ro ws(0)("dspcash" )
    iLCash = dsLCash.Tabls(" localcash").Row s(0)("lcash")

    lblTCash.Text = iDCash + iLCash 'this is the 2 rounded values put together

    Any ideas on how to get lblTCash.Text to equal lblDSPCash.Text added mathematically to lblLCash.Text??
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    Take each text, convert to a float, add the floats, present as formatted text

    Code:
    lblTCash.Text =( ((Convert.ToFloat(dsDSPcash.Text )) 
                   + ((Convert.ToFloat(lblLcash.Text )) ).ToString();
    // Format as you like

    Comment

    Working...