Need help with writing code for a pricing system

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I'm very new to Visual Basic .Net, I am stuck on a piece of programming and
in need of some help!

I don't know whether I should be using a 'For... Next Loop' or a 'Do...
Loop' (?) The calculation involves 7 checkboxes (of different values), that
should be added together (when selected), and then multiplied to create a
'total cost'

Any hints or tips would be greatly appreciated

Many thanks
 
Brad, To use either, you will need the checkboxs in a collection (or array)
of some sort. The easy way to do this is the put a panel on your form and
then put the checkboxes in the panel. The checkboxes will now be in the
controls collection of the panel and you can use a "foreach" to loop through
the collection.

Depending on your newness to vb and programming, you might want to pick to
some of the book MS recommends on their vb site. The system is lot to get
your arms around with out some documentation to give you a framework.

Best of luck...Chuck
 
Brad,

My idea is, forever when you can use a for (index) or foreach in VBNet, than
use those.

If you set (only) those checkboxes by instance in a seperated groupbox than
you can do (roughly typed in htis message and assuming that you have set the
value in the text)

\\\
dim totalvalue as Integer
for each chk as control in groupbox1.controls
dim chkbox = directcast(chk,checkbox)
'with this you can handle it as a checkbox
if directcast(chkbox, checkbox).checked then
totalvalue = Cint(chkbox.text)
end if
next
///

I hope this helps,

Cor
 
Back
Top