![]() |
#1
|
|||
|
|||
![]()
Sub phoenixmoto()
With UserForm1 .wow.Value = True With .comb .AddItem "addition" .AddItem "subtraction" End With .comb.Value = "subtraction" .TextBox1.Value = 10 .TextBox2.Value = 20 .TextBox3.Value = 30 .Show End With Unload UserForm1 End Sub Private Sub cancel_Click() hide End Sub Private Sub ok_Click() Dim a As Variant, b As Variant, c As Variant If TextBox1.Value = "" Then MsgBox "a field is empty" Exit Sub End If If TextBox2.Value = "" Then MsgBox "b field is empty" Exit Sub End If If TextBox3.Value = "" Then MsgBox "c field is empty" Exit Sub End If a = TextBox1.Value b = TextBox2.Value c = TextBox3.Value If wow.Value = True Then Select Case comb Case "addition" Call ad(a, b, c) Case "subtraction" Call minus(a, b, c) End Select End If hide End Sub Sub ad(a As Variant, b As Variant, c As Variant) ThisDocument.TextBox10.Value = amrit(a, b, c) End Sub Sub minus(a As Variant, b As Variant, c As Variant) ThisDocument.TextBox10.Value = sam(a, b, c) End Sub Public Function amrit(a As Variant, b As Variant, c As Variant) As Variant amrit = (a + b + c) End Function Public Function sam(a As Variant, b As Variant, c As Variant) As Variant sam = (a - b - c) End Function here in this code function sam works fine and delivers -40 as answer but function amrit does concatination(102030) instead of sum(i.e 60) how + symbol is working like & |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
subtract date and time and convert to decimal hours ? | DBenz | Excel | 5 | 01-26-2017 05:38 AM |
![]() |
Jue92 | Excel | 4 | 11-01-2016 01:45 AM |
Subtract value from one cell into another | otuatail | Excel | 3 | 02-01-2016 03:21 AM |
Use a numerical merge field to subtract that number of months | MichaelSpedding | Mail Merge | 8 | 11-11-2015 01:11 PM |
![]() |
nitemath2 | Excel | 1 | 06-19-2015 01:28 AM |