adding doubles - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

adding doubles

satsocsatsoc Posts: 19Member
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?

Comments

  • slicer69slicer69 Posts: 272Member
    : 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)
  • satsocsatsoc Posts: 19Member
    : : 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.
  • hobbyhobby Posts: 84Member
    : : : 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)
Sign In or Register to comment.