Good day,
I have two Userforms.
You can see the first one as the parentform so to speak and the second one
as the subform.
Now what I want to do when I'm finished with te subform is: sum up a digit
in the subform with a digit on the parentform and then replace the last digit
with the outcome. But when I try this with a simple 'formula' like:
Dim i As Double
i = frmParent.lblTotal.Caption + lblPremium.Caption
frmParent.lblTotal.Caption = i
VBA treats my outcome as a string. This means that when the caption was 100
and de new outcome would be 10 then it doesn't say 110 but 10010!!!
Now I know I have to use something like i = CDbl(frmParent.lblTotal.Caption
+ etc.
But I cant get it to work, can somebody help???
Greg Maxey - 04 May 2006 13:01 GMT
Try something like:
Sub Test()
Dim ptest1 As String
Dim ptest2 As String
Dim i As Long
ptest1 = 100
ptest2 = 10
i = CDbl(ptest1) + CDbl(ptest2)
MsgBox i
End Sub
Guus van Waardenburg - 04 May 2006 14:43 GMT
Yes! Thanks Greg,
Apart from some minor changes this worked great!
> Try something like:
>
[quoted text clipped - 7 lines]
> MsgBox i
> End Sub