# sum "+" in vb RSS

## 6 replies

Last post Nov 08, 2012 06:21 PM by vadz

Member

6 Points

22 Posts

### sum "+" in vb

Nov 08, 2012 01:59 AM|LINK

i have a 3 values and i want to sum it up using vb. a,b and c....so after i got those values i want to sum it up using sum =a+b+c this i do at the end of my if statement..and return(sum)..it does not do anthing on it nor add those value. if i got a= 75 and b=6 it only return 75 but not 81

Participant

1135 Points

410 Posts

### Re: sum "+" in vb

Nov 08, 2012 02:51 AM|LINK

Please post your code so that we can understand the things better

Mark this post as answer if it helps you!!!

Regards
Sangamesh Belawatgi,
Software Developer,
Bangalore - INDIA

Participant

1135 Points

410 Posts

### Re: sum "+" in vb

Nov 08, 2012 02:51 AM|LINK

Please post your code so that we can understand the things better

Mark this post as answer if it helps you!!!

Regards
Sangamesh Belawatgi,
Software Developer,
Bangalore - INDIA

All-Star

31764 Points

6492 Posts

### Re: sum "+" in vb

Nov 08, 2012 03:11 AM|LINK

```dim a as integer = 75
dim b as integer = 6
dim c as integer = 0

dim sum as integer = a + b + c```

Programming to simplify, dont look for hard way

Member

6 Points

22 Posts

### Re: sum "+" in vb

Nov 08, 2012 04:22 AM|LINK

```here is my code.my sum values not working fine..if i enter 365 and 30 for second textbox it gives 730 instead of 395.
Sum values does ot return anything.```
```Public Function test(length  As string) As Integer

dim len1 As integer
dim len2 As integer
dim len3  As integer
dim sum  as string

if length =0
Return String.Empty
end if

if length >365.25 then
len1 =length/ 365.25
length =length  Mod 365.25
length = len1 *365.25
len1 = length

end if

if length>31 And length<366 then
len2=length/30.4375
length=length  Mod 30.4375
length=len2* 30.4375
len2=length

end if

if length<31 Then
len3 =length

end if

sum = len1  + len2 +len3

return(sum)

End Function```

thanks

```
```

• Edited by vadz on Nov 08, 2012 04:24 AM
• Edited by vadz on Nov 08, 2012 04:25 AM
• Edited by vadz on Nov 08, 2012 04:26 AM
• Edited by vadz on Nov 08, 2012 04:29 AM

All-Star

31764 Points

6492 Posts

### Re: sum "+" in vb

Nov 08, 2012 06:01 AM|LINK

```dim len1 As Double
dim len2 As Double
dim len3  As Double
Dim sum As Double
.
.
.
.

Return sum.ToString()```
`Calculate values in number type, then convert to string the resultI think you need to change var type to double`
Programming to simplify, dont look for hard way
• Edited by oned_gk on Nov 08, 2012 06:03 AM
• Edited by oned_gk on Nov 08, 2012 06:06 AM
• Edited by oned_gk on Nov 08, 2012 06:06 AM
• Edited by oned_gk on Nov 08, 2012 06:09 AM
• Marked as answer by vadz on Nov 08, 2012 07:03 PM

Member

6 Points

22 Posts

### Re: sum "+" in vb

Nov 08, 2012 06:21 PM|LINK

hi oned_gk

thanks you sooo much!!..it works..:)