Hello
i have a form with 4 text box. TB1 to TB4. TB1 and TB2 accept numbers and TB3 is the start date TB4 is end date i.e. TB1 + TB2 + TB3.
i am not able add TB1 and TB2 it concatenating them i.e. if i enter 1 in TB1 and 1 in TB2 it should add 2 to TB3 but it is adding 11.
Private Sub TB2_Change()
Dim sResult As String
Dim TB1, TB2 As String
Dim DateFrom As Date
Dim ExtraDays As Double
TB1 = Me.TB1.Value
TB2 = Me.TB2.Value
DateFrom = Me.TB3.Value
ExtraDays = (TB1 + TB2)
If IsNull(TB1) Or TB1 = "" Then
ExtraDays = Sum("0" + TB2)
sResult = DateAdd("d", ExtraDays, DateFrom)
Else
ExtraDays = Sum(TB1 + TB2)
sResult = DateAdd("d", ExtraDays, DateFrom)
End If
Me.TB4.Value = sResult
Me.TB4 = Format(Me.TB4, "dd mmm yyyy")
End Sub
i even tried
- ExtraDays = val(TB1 + TB2)
- ExtraDays = CInt(TB1 + TB2)
none of these work it adds 11 instead of 2
i have posted this on https://www.mrexcel.com/forum/excel-...elds-date.html too.
Bookmarks