Results 1 to 2 of 2

Thread: Probably Simple!

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2000
    Posts
    34

    Question

    Hi, I am just a beginner with VB. I'm trying to get numbers to total on a form using text boxes. I can get it to work with a command_click but would prefer if it would total on it's own, no command_click button. eg: enter number in text1 number shows up also in text3 (assuming this is the totaling text box).
    This is the code I'm using presently with the command_click.
    Private Sub Command1_Click()
    Dim intNoA As Integer
    Dim intNoB As Integer
    intNoA = Text1
    intNoB = Text2
    Text3 = intNoA + intNoB
    End Sub
    This is probably simple so please have patience with me.
    I certainly appreciate you taking the time to respond to this request.
    Thanks, newvbr

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    Private Sub Text2_Change()
        Text3 = Val(Text1) + Val(Text2)
    End Sub
    'of course you will need to validate your text
    'numbers only...for each box
    Code:
    'allow only numeric data in a textbox
    
    Option Explicit
    
    Private Sub Text1_KeyPress(KeyAscii As Integer)
     If Not IsNumeric(Chr(KeyAscii)) Then KeyAscii = 0
    End Sub


    [Edited by HeSaidJoe on 11-23-2000 at 02:41 PM]
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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