Connecting Tech Pros Worldwide Forums | Help | Site Map

Adding String Values

Newbie
 
Join Date: Mar 2009
Posts: 16
#1: Jun 1 '09
I've got 2 labels (lblDSPCash and lblLCash) that are setup:

Format(dsDSPCash.Tables("dspcash").Rows(0)("dspcas h"), "Currency")

and

Format(dsLCash.Tabls("localcash").Rows(0)("lcash") , "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.Tables("dspcash").Rows(0)("dspcash")
iLCash = dsLCash.Tabls("localcash").Rows(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's Avatar
Moderator
 
Join Date: Mar 2008
Location: Arizona, USA
Posts: 1,765
#2: Jun 1 '09

re: Adding String Values


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

Expand|Select|Wrap|Line Numbers
  1. lblTCash.Text =( ((Convert.ToFloat(dsDSPcash.Text )) 
  2.                + ((Convert.ToFloat(lblLcash.Text )) ).ToString();
  3. // Format as you like
Reply

Tags
adding, addition, strings, values