Click here to Skip to main content
15,908,173 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralExcuse me, but... Pin
3-Dec-04 3:54
suss3-Dec-04 3:54 
GeneralDesktop Icons Pin
GRMartin3-Dec-04 1:46
GRMartin3-Dec-04 1:46 
GeneralRe: Desktop Icons Pin
MohammadAmiry4-Dec-04 2:53
MohammadAmiry4-Dec-04 2:53 
GeneralCrystal Report Pin
nitin_ion2-Dec-04 22:07
nitin_ion2-Dec-04 22:07 
GeneralRe: Crystal Report Pin
Tom John2-Dec-04 22:18
Tom John2-Dec-04 22:18 
GeneralVB6 - How to list network domains and/or users Pin
steff kamush2-Dec-04 21:11
steff kamush2-Dec-04 21:11 
GeneralRe: VB6 - How to list network domains and/or users Pin
jonathan152-Dec-04 23:09
jonathan152-Dec-04 23:09 
Generalaccess database question Pin
Member 14960382-Dec-04 14:41
Member 14960382-Dec-04 14:41 
GeneralRe: access database question Pin
doWhileSomething4-Dec-04 15:15
doWhileSomething4-Dec-04 15:15 
GeneralQuestion about sale Pin
safran662-Dec-04 12:58
safran662-Dec-04 12:58 
GeneralRe: Question about sale Pin
Purple Monk3-Dec-04 4:02
Purple Monk3-Dec-04 4:02 
GeneralRe: Question about sale Pin
safran663-Dec-04 18:54
safran663-Dec-04 18:54 
GeneralRe: Question about sale Pin
MohammadAmiry4-Dec-04 2:49
MohammadAmiry4-Dec-04 2:49 
GeneralFree reporting tool Pin
Mekong River2-Dec-04 10:04
Mekong River2-Dec-04 10:04 
GeneralRe: Free reporting tool Pin
safran662-Dec-04 12:44
safran662-Dec-04 12:44 
Generalserialization of datagridtablestyle Pin
frush1232-Dec-04 8:18
frush1232-Dec-04 8:18 
GeneralRe: serialization of datagridtablestyle Pin
Tom John3-Dec-04 2:03
Tom John3-Dec-04 2:03 
GeneralRe: serialization of datagridtablestyle Pin
frush1233-Dec-04 2:07
frush1233-Dec-04 2:07 
GeneralRe: serialization of datagridtablestyle Pin
Tom John3-Dec-04 2:41
Tom John3-Dec-04 2:41 
GeneralRe: serialization of datagridtablestyle Pin
frush1233-Dec-04 2:59
frush1233-Dec-04 2:59 
GeneralRe: serialization of datagridtablestyle Pin
Tom John3-Dec-04 3:14
Tom John3-Dec-04 3:14 
GeneralRe: serialization of datagridtablestyle Pin
Anonymous3-Dec-04 12:21
Anonymous3-Dec-04 12:21 
GeneralProblems with code Pin
Tech 4 a dummy2-Dec-04 4:28
Tech 4 a dummy2-Dec-04 4:28 
This is a code to calculate a class average. I am trying to modify the btnAverage_click event handler so that intGraderCounter is incremented until it is equal to the number of grades entered, and by using the 1stGrades.Items.Count to determine the number of items in the listbox. The number returned by the count property will be 0 if there are no grade entered. I need to use and if… then selection statement to avoid division by zero and to display a message dialog to the user if there are no grades entered when the user clicks the Average button. I also need help on modifying the code in the btnAverage_Click event handler so that the dblAverage is computed by using the intGraderCounter rather than the value 10. I tried all sorts of things that I could do but the program is still not running right. The code is below...


' handles Add Grade Button's Click event
Private Sub btnAdd_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnAdd.Click

' clear previous grades and calculation result
If lblOutput.Text <> "" Then
lblOutput.Text = ""
lstGrades.Items.Clear()
End If

' display grade in ListBox
lstGrades.Items.Add(Val(txtInput.Text))
txtInput.Clear() ' clear grade from TextBox
txtInput.Focus() ' transfer focus to TextBox

'' prohibit users from entering more than 10 grades
'If lstGrades.Items.Count >= 10 Then
' btnAdd.Enabled = False ' disable Add Grade Button
' btnAverage.Focus() ' transfer focus to Average Button
'End If

End Sub ' btnAdd_Click

' handles Average Button's Click event
Private Sub btnAverage_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnAverage.Click

' initialization phase
Dim intTotal As Integer = 0
Dim intGradeCounter As Integer = 0
Dim intGrade As Integer = 0
Dim dblAverage As Double = 0

' sum grades in ListBox
Do

' read grade from ListBox
intGrade = lstGrades.Items.Item(intGradeCounter)
intTotal += intGrade ' add grade to total
intGradeCounter += 1 ' increment counter
Loop Until intGradeCounter >= 10

dblAverage = intTotal / 10 ' calculate average
lblOutput.Text = String.Format("{0:F}", dblAverage)
btnAdd.Enabled = True ' enable Add Grade Button
txtInput.Focus() ' reset focus to Enter grade: TextBox
End Sub ' btnAverage_Click

Private Sub FrmClassAverage_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub
End Class ' FrmClassAverage




Need Help!!!!!!!
GeneralRe: Problems with code Pin
The Man from U.N.C.L.E.2-Dec-04 5:28
The Man from U.N.C.L.E.2-Dec-04 5:28 
GeneralRe: Windows Services CPU Usage Problem Pin
Dave Kreskowiak2-Dec-04 1:23
mveDave Kreskowiak2-Dec-04 1:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.