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
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
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
heyitsme
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
Regards
Sangamesh Belawatgi,
Software Developer,
Bangalore - INDIA
heyitsme
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
Regards
Sangamesh Belawatgi,
Software Developer,
Bangalore - INDIA
oned_gk
All-Star
31764 Points
6492 Posts
Re: sum "+" in vb
Nov 08, 2012 03:11 AM|LINK
vadz
Member
6 Points
22 Posts
Re: sum "+" in vb
Nov 08, 2012 04:22 AM|LINK
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 Functionthanks
oned_gk
All-Star
31764 Points
6492 Posts
Re: sum "+" in vb
Nov 08, 2012 06:01 AM|LINK
vadz
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..:)
