+ Reply to Thread
Results 1 to 2 of 2

calculating textboxes

  1. #1
    enyaw
    Guest

    calculating textboxes

    I have four textboxes. 3 of them are multiplied by each other to get the
    answer in the fourth box. Sometimes there is not information for the first
    three boxes so the fourth textbox must be inputted manually. I need to able
    to automatically calculate when there is information and manually input when
    there is none. I need some coding to be able to this. I also need to
    disable the total box when calculating manually but enable it when entering
    manually. Can anyone help?

  2. #2
    SyrNO
    Guest

    RE: calculating textboxes

    I don't know if this is the most efficient way to do this, but it works. Try
    the following code for the Exit Event for each of the 3 text boxes,

    Private Sub txt1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    Dim v1 As Double
    Dim v2 As Double
    Dim v3 As Double

    If txt1.Value = "" And txt2.Value = "" And txt3.Value = "" Then
    txt4.Enabled = True
    Else:
    txt4.Enabled = False
    If txt1.Value = "" Then
    v1 = 1
    Else:
    v1 = txt1.Value
    End If
    If txt2.Value = "" Then
    v2 = 1
    Else:
    v2 = txt2.Value
    End If
    If txt3.Value = "" Then
    v3 = 1
    Else:
    v3 = txt3.Value
    End If
    txt4.Value = v1 * v2 * v3
    End If

    End Sub

    "enyaw" wrote:

    > I have four textboxes. 3 of them are multiplied by each other to get the
    > answer in the fourth box. Sometimes there is not information for the first
    > three boxes so the fourth textbox must be inputted manually. I need to able
    > to automatically calculate when there is information and manually input when
    > there is none. I need some coding to be able to this. I also need to
    > disable the total box when calculating manually but enable it when entering
    > manually. Can anyone help?


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1