|
-
Aug 14th, 2007, 03:46 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] [02/03] Breaking down a mathematical answer
Hello guys!
This should be a breeze for all you pros out there.
I have this sub:
Code:
Private Sub suggWeekLimitCalc(ByVal Limit As Integer)
Dim TempWeeks As Integer
Dim iIndex As Integer
Dim avgWeeks As Single
Dim modWeeks As Integer
avgWeeks = WeekLimit / sugNumSubjects
modWeeks = WeekLimit Mod sugNumSubjects
ReDim sugSubDurArr(sugNumSubjects)
For iIndex = 1 To sugNumSubjects
sugSubDurArr(iIndex) = WeekLimit - avgWeeks
Next iIndex
MessageBox.Show(avgWeeks.ToString())
End Sub
Now, what is supposed to happen here is:
I get a certain amount of weeks, let's presume I get 21 weeks. (This I get somewhere else). This sub (the above sub), is supposed to break down that number of weeks.
For example, I select 4 subjects, then, I select a duration in months - let's presume I selected 5 months.
Currently, it returns 21.
Now, what I'm hoping to achieve with the above sub, is to split the 21 weeks into 4 seperate variables (or elements of an array). The way it would be split would be:
Array Index 1 = 5
Array Index 2 = 5
Array Index 3 = 5
Array Index 4 = 6
Which adds up to 21.
The real problem i'm sitting with is the For Loop. It just keeps on subtratcing the current value of avgWeeks, instead of decrementing avgweeks. This is the results the Loop produces currently:
Array Index 1 = 16
Array Index 2 = 16
Array Index 3 = 16
Array Index 4 = 16
And so on. It just keeps subtracting 5 once, and not again.
Can anyone help me out on this?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|