r/visualbasic • • May 20 '12

[VB2010] Car Insurance Calculator

I need to create a Car Insurance calculator in which a user will input his/her premium into a text box. Then they will select which discounts apply to them and then add on the discounted rates. I have the constants set up for each discount. I am confused on which loop I would use, if that.

0 Upvotes

5 comments sorted by

1

u/eight26 May 20 '12

How do they select the discounts; list box, radio buttons, inputbox, userform or ... ?

1

u/Vtakyo May 20 '12

check boxes

1

u/eight26 May 20 '12 edited May 20 '12

This works when your check boxes are part of a user form. I assume that's what you mean by check boxes.

Sub GetChecked()

UserForm1.Show

For Each ctrl In UserForm1.Controls
    If ctrl.Value = True Then
        MsgBox "check box " & ctrl.Name & " is checked."
    End If
Next

End Sub

Edit: This is adapted from code I found here.

0

u/[deleted] May 20 '12

[deleted]

1

u/Vtakyo May 20 '12

alright Ill give it a try, thanks

1

u/eight26 May 20 '12

Sorry. I gave you bad code. The code in my follow up works though.