Begin:
Add to the form the textboxes with index=0
Textboxes for : Operation(0) , Hours(0) , Min(0) , ...
The best way is to go in 3 steps:
1- Update display on clicking the Operation command (+, -, ..):
Add textboxes with "Load" from the original ones (Operation(0) , Hours(0),...) with index= ubound + 1
set the Top of the new textboxes in function of the index like:
- Load Text1(Text1.UBound + 1)
-
Text1(Text1.UBound).Top = Text1(Text1.UBound - 1).Top + 600
-
Text1(Text1.UBound).Visible = True
2- calculate in function of the Operation command.
!!! calculate with the lowest unit (sec, milsec, ...)=
If the lowest unit= sec. => set hours to sec, set min to sec,... make the operations for index (of one component like: TextboxHours) from Lbound to Ubound.
- for i= textHours.lbound to textHours.ubound
-
Select case Operation(i).caption
-
case "+": Result= Result + (textHours(i)*3600) + (textMin(i)*60) +...
-
case "-": Result=Result - ...
-
end select
-
next
3- Adapt the display in function of the result=
hours= int(result/3600)
minutes = int((result - hours )/60)
...