Results 1 to 5 of 5

Thread: sum 2 textbox

  1. #1

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Red face

    How I sum 2 values with fractions which are in the textbox, I try with val function, but it give me only the integer part. I want all

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    What are you doing? it's int that gives the integer part not val.
    Post the code
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709
    txttotal_exame.Text = Format((Val(txt_ValorExame.Text) * 100 + Val(txt_ValorKit) * 100) / 100, "###,##0.00")

    txt_valorExame = 186.53
    txt_ValorKit = 23.62

    It give me in txtTotal_exame = 209.00, It is sum only

    186 + 23


    thank you in advance

  4. #4
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840
    Try this

    Code:
    Private Sub Command1_Click()
    
        Dim txt1 As Single
        Dim txt2 As Single
        
        txt1 = CSng(Text1.Text)
        txt2 = CSng(Text2.Text)
        
        Label1.Caption = Str(txt1 + txt2)
    
    End Sub
    ...and have a good weekend...
    Paul Dwyer
    Network Engineer
    Aussie In Tokyo

    Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    This explains your problem
    Code:
    ?Format((Val("1,26767") * 100 + Val("1,3") * 100) / 100, "###,##0.00") 
    2,00
    ?Format((Val("1.26767") * 100 + Val("1.3") * 100) / 100, "###,##0.00") 
    2,57
    I hope you understand what's wrong
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width