Beginner VB

Moderators: None (Apply to moderate this forum)
Number of threads: 1233
Number of posts: 2978

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
adding doubles Posted by satsoc on 7 Apr 2002 at 3:21 PM
hello ppl
i have to calculate a*b/a+b,dim b as double,a=var(Text1.Text),but the result is wrong.i think that something is not right when adding var() with double.Can anybody help?
Report
double trouble Posted by slicer69 on 7 Apr 2002 at 3:29 PM
: hello ppl
: i have to calculate a*b/a+b,dim b as double,a=var(Text1.Text),but the result is wrong.i think that something is not right when adding var() with double.Can anybody help?
:

dim b as double
dim c as double

c = double(Text1.text)
result = (c * b) / (c + b)
Report
Re: double trouble Posted by satsoc on 8 Apr 2002 at 2:41 AM
: : hello ppl
: : i have to calculate a*b/a+b,dim b as double,a=var(Text1.Text),but the result is wrong.i think that something is not right when adding var() with double.Can anybody help?
: :
:
: dim b as double
: dim c as double
:
: c = double(Text1.text)
: result = (c * b) / (c + b)
:
man i tried that double(Text1.Text) but it doesn't seem to be recognised by the compiler.
Report
Re: double trouble Posted by hobby on 8 Apr 2002 at 8:04 AM
: : : hello ppl
: : : i have to calculate a*b/a+b,dim b as double,a=var(Text1.Text),but the result is wrong.i think that something is not right when adding var() with double.Can anybody help?
: : :
: :
: : dim b as double
: : dim c as double
: :
: : c = double(Text1.text)
: : result = (c * b) / (c + b)
: :
: man i tried that double(Text1.Text) but it doesn't seem to be recognised by the compiler.
:

Try:

c = CDbl(Val(Text1.text))

or

c = CDbl(Text1.text)

The Val() function just converts text1.text to a number (or tries to at least), but it may not be necessary if you only have numbers (i.e. Val could convert A1 to 1)



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.