## 6 replies

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

Member

2 Points

19 Posts

### sum "+" in vb

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

• heyitsme

Participant

1067 Points

545 Posts

### Re: sum "+" in vb

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

• heyitsme

Participant

1067 Points

545 Posts

### Re: sum "+" in vb

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

• oned_gk

All-Star

51321 Points

15145 Posts

### Re: sum "+" in vb

```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, don't look for difficult way

Member

2 Points

19 Posts

### Re: sum "+" in vb

```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

```
```

• oned_gk

All-Star

51321 Points

15145 Posts

### Re: sum "+" in vb

```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, don't look for difficult way

Member

2 Points

19 Posts