Post

 Resources 

Console

Home | Profile | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 VBGamer
 VBGamer
 addition prob
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Dark_Lord
Squire

12 Posts

Posted - May 29 2006 :  10:19:51 AM  Show Profile  Reply with Quote
hello everyone, please help me out with adding the caption of several labels. I had been doing ithese additions but now i am not able because i stopped programming for some years

here is the script

tHrs.Caption = hrs1.Caption + hrs2.Caption + hrs3.Caption + hrs4.Caption + hrs5.Caption + hrs6.Caption

Thanks

Edited by - Dark_Lord on May 29 2006 10:48:43 AM

d-skyman
Neophyte

Germany
1 Posts

Posted - May 29 2006 :  6:18:44 PM  Show Profile  Visit d-skyman's Homepage  Send d-skyman an ICQ Message  Click to see d-skyman's MSN Messenger address  Reply with Quote
Hey Lord,

I think you would have to use the "&" symbol, not the "+" sign.

regards, d-skyman

Go to Top of Page

Dark_Lord
Squire

12 Posts

Posted - May 30 2006 :  11:32:04 AM  Show Profile  Reply with Quote
Hey Skyman, Thanks for you reply, but both + and & gives the same result which i dont want. I want to add the values.

I will explain what i mean as such.
Let say hrs1 = 4, hrs2 = 5
so according to this code, the resultant value would not be equal to the sum of 4 & 5 infact it would be 45. That is it does not add them but writes them together.
Please help me.

Thanks
Go to Top of Page

Dark_Lord
Squire

12 Posts

Posted - May 30 2006 :  11:35:59 AM  Show Profile  Reply with Quote
i want it to be added that is 4 + 5 = 9
Go to Top of Page

Eric Coleman
Gladiator

USA
811 Posts

Posted - May 30 2006 :  3:12:51 PM  Show Profile  Visit Eric Coleman's Homepage  Reply with Quote
The previous code I wrote won't work. Try this instead.
  
tHrs.Caption = CNum(hrs1.Caption) + CNum(hrs2.Caption) + CNum(hrs3.Caption) + CNum(hrs4.Caption) + CNum(hrs5.Caption) + CNum(hrs6.Caption)  
  
Public Function CNum(ByVal X As Variant) As Variant
If IsNumeric(X) = True Then
CNum = CDbl(X)  
Else
CNum = 0  
End If
End Function
  
Go to Top of Page

Dark_Lord
Squire

12 Posts

Posted - Jun 01 2006 :  04:07:19 AM  Show Profile  Reply with Quote
Thanks Eric Coleman, It works now.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
VBGamer © Go To Top Of Page
This page was generated in 0.09 seconds. Snitz Forums 2000

Copyright © 2002 - 2004 Eric Coleman, Peter Kuchnio , et. al.