Results 1 to 3 of 3

Thread: Add numbers dynamically

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2001
    Location
    Dallas, TX
    Posts
    1

    Question Add numbers dynamically

    Can somebody help me...on how to do the following? I have 4 number fields in a form.....I want to add those to the total field each time I tab from one field to another....(ie Add dynamically)

    Thanks

  2. #2
    Addicted Member
    Join Date
    Jul 2000
    Location
    California
    Posts
    154
    do you mean like this

    Code:
    'add four textboxes and one label 
    
    
    Private Sub Text1_Validate(Cancel As Boolean)
    Label1.Caption = Text1.Text
    
    End Sub
    
    
    
    Private Sub Text2_Validate(Cancel As Boolean)
    Label1.Caption = Int(Label1.Caption) + Text2.Text
    End Sub
    
    
    
    Private Sub Text3_Validate(Cancel As Boolean)
    Label1.Caption = Int(Label1.Caption) + Text3.Text
    
    End Sub
    
    
    
    Private Sub Text4_Validate(Cancel As Boolean)
    Label1.Caption = Int(Label1.Caption) + Text4.Text
    End Sub
    VB-World addict!

    All spelling errors are undocumented words!
    http://www.bells.f2s.com

  3. #3
    Frenzied Member
    Join Date
    Jul 1999
    Location
    Huntingdon Valley, PA 19006
    Posts
    1,151

    LostFocus.

    Write code for the LostFocus Event which will do conversions and addition to the total.

    You will probably need a Boolean variable which gets set by the Change event for the Textbox and reset by the LostFocus event. If you are not careful, you will add the same amount to the total twice.
    Live long & prosper.

    The Dinosaur from prehistoric era prior to computers.

    Eschew obfuscation!
    If a billion people believe a foolish idea, it is still a foolish idea!
    VB.net 2010 Express
    64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.

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