|
-
Apr 14th, 2005, 11:59 PM
#3
Thread Starter
New Member
Re: VB Array Question
 Originally Posted by mendhak
Homework?
Show us exactly where you're stuck, and show the code you've got so far.
as for the homework ?
Yes, I've been working on it since monday but now I'm just not getting it so I'm giving in and seeking help!
It's due 2morrow morning at 11:00 AM EXACTLY
_____________________________
Warning just in the middle of trying something different so everything is all over the place, but here it is:
Private Sub btnRun_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRun.Click
'Array to hold the frequency of each result
Dim sum(3) As Integer
Dim overAllSum As Integer = 168 'initialize overall sum of summed rolls
Dim rollCount As Integer = 0 'initialize count of all rolls
Dim overAllAverage As Decimal 'to hold over the all average
Dim oneRoll As Integer
Dim count As Integer
Dim dieA As Integer
Dim dieB As Integer
Dim dieC As Integer
Dim dieD As Integer
For Each rollCount In tally
oneRoll = processOneRoll()
lstFrequencyTable.Items.Add(processDisplayList())
count += 1
Next rollCount
'average the results and display in label
'overAllAverage = (overAllSum / rollCount)
lblOverAllAverage.Text = "The average result is: " & FormatNumber(overAllAverage, 2)
End Sub
Sub processDisplayList(ByVal die1 As Integer, ByVal die2 As Integer, _
ByVal die3 As Integer, ByVal die4 As Integer, _
ByVal count As Integer)
lstFrequencyTable.Items.Add((count) & " (" & die1 & ", " & _
die2 & ", " & die3 & ", " & die4 & ")")
End Sub
Function processOneRoll() As Integer
Dim dieA As Integer
Dim dieB As Integer
Dim dieC As Integer
Dim dieD As Integer
Dim sum As Integer
dieA += 1
dieB += dieA
dieC += dieA
dieD += dieA
sum = die2 + die3 + die4
Return sum
End Function
End Class
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
|