Results 1 to 6 of 6

Thread: keeping a running total

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2000
    Posts
    18
    how do you set a text box to keep a running total of a the total value of the numbers in a couple of other text boxes.

  2. #2
    Guest
    Code:
    Text1.text = Len(Text2.text)
    This will keep a word count writing to text1 of how many words are in text2.

  3. #3
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523
    And this will add three textboxes together (as the user types) and it will add the result to the fourth textbox
    Code:
    Option Explicit
    
    Private Sub Text2_Change()
        Text1 = Val(Text2) + Val(Text3) + Val(Text4)
    End Sub
    
    Private Sub Text3_Change()
        Text1 = Val(Text2) + Val(Text3) + Val(Text4)
    End Sub
    
    Private Sub Text4_Change()
        Text1 = Val(Text2) + Val(Text3) + Val(Text4)
    End Sub

  4. #4
    Guest
    adam3000 how do you set a text box to keep a running total of a the total value of the numbers in a couple of other text boxes.
    Oops, didn't see the value part . Anyway, what does Val() do?

    Val() = Returns the numbers contained in a string.

    Anyone care to explain more?

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Try put this in a immediate window
    ?val(" 1 2 345 6.7 8,9 hsfg h 56 34")
    You'll notice that Val searches for the number's, ignores spaces, stops whenever it finds other characters, only accepts "." as decimal separator
    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.

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Jul 2000
    Posts
    18
    I had just figured that out but wasen't sure if that was the best way to do it. now i know. Thanks.

    Originally posted by QWERTY
    And this will add three textboxes together (as the user types) and it will add the result to the fourth textbox
    Code:
    Option Explicit
    
    Private Sub Text2_Change()
        Text1 = Val(Text2) + Val(Text3) + Val(Text4)
    End Sub
    
    Private Sub Text3_Change()
        Text1 = Val(Text2) + Val(Text3) + Val(Text4)
    End Sub
    
    Private Sub Text4_Change()
        Text1 = Val(Text2) + Val(Text3) + Val(Text4)
    End Sub

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