#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default How do I?

How do I add the total of two tetboxes together in vb code. I need the total
displayed in a textbox called "total"
the textboxes are "f5" & "f6"

Thanks

Greg


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default How do I?

Use the chaneg events for the two "input" boxes to call a proc that
will update the total box. You will also need to handle errors and
non-numeric input. The basics are below. Please let me know if this
is what you were looking for.

Private Sub f5_Change()

RecalcTotal

End Sub

Private Sub f6_Change()

RecalcTotal

End Sub

Private Sub RecalcTotal()

Dim dblF5 As Double
Dim dblF6 As Double

If IsNumeric(Me.f5.Value) And IsNumeric(Me.f6.Value) Then

dblF5 = CDbl(Me.f5.Value)
dblF6 = CDbl(Me.f6.Value)

Me.total.Value = dblF5 + dblF6

Else

'handle non numeric input here

End If

End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 02:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"