Results 1 to 3 of 3

Thread: How sum 2 textbox ?

  1. #1

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

    Angry

    Hi

    Please, How I sum 2 textboxs with decimal, I tried with val function and It give me only integer part

  2. #2
    Addicted Member
    Join Date
    Jun 1999
    Location
    Los Angeles
    Posts
    186
    Hi there, I have no problems with this.
    But you must make sure of what separator of decimals you use.On my machine if I sum 2.2 + 2.12345 I get 4,32345, BUT if I write 2,2 + 2,12345 I get 4!!!, notice it works with dot, but not with comma, I guess this is what you need to do.

    André

  3. #3
    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!)

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