Jiskha Homework Help
SATURDAY
November 21, 2009
SCHOOL SUBJECTS
- Art
- Business
- Computers
- English
- Foreign Languages
- Health
- Home Economics
- Math
- Music
- Physical Education
- Science
- Social Studies
GRADE LEVELS
- Preschool
- Kindergarten
- Elementary School
- 1st Grade
- 2nd Grade
- 3rd Grade
- 4th Grade
- 5th Grade
- 6th Grade
- 7th Grade
- 8th Grade
- High School
- 9th Grade
- 10th Grade
- 11th Grade
- 12th Grade
- College
- Adult Education
Post a New Question | Current Questions | Chat With Live Tutors

Homework Help Forum: visual basic

Posted by cl on Thursday, May 7, 2009 at 4:58pm.

Cant get my message dialog box to display anbody see waht wrong with it? The message box is located in my if then else statement


Dim total As Integer = 0
Dim gradeCounter As Integer = 0
Dim grade As Integer = 0
Dim average As Double = 0

' sum grades in ListBox
Do
' read grade from ListBox
grade = gradesListBoxItemsItem(gradeCounter)
total += grade ' add grade to total
gradeCounter += 1 ' increment counter

Loop Until gradeCounter = gradesListBoxItemsCount()

average = total / gradesListBoxItemsCount() ' calculate average
averageResultLabel.Text = String.Format("{0:F}", average)
addButtonEnabled = True ' enable Add Grade Button
gradeTextBoxFocus() ' reset focus to Enter grade: TextBox

If (gradeCounter = " ") Then
MessageBoxShow( _
"There are not any grades entered", _
"Average can not be divided by zero", MessageBoxButtonsOK, _
MessageBoxIconError)
Else

End If

  • visual basic - Quidditch, Thursday, May 7, 2009 at 5:50pm

    gradeCounter is defined as Integer.
    Try:
    If(gradeCounter = 0)...

  • visual basic - RickP, Thursday, May 7, 2009 at 10:45pm

    In VB, you should use OPTION EXPLICIT whenever possible in order to let the 'compiler' endorce strong typing.

Answer this Question

First Name:
School Subject:
Answer:

SEARCH

COMMUNITY
FEATURES
- Live Tutors
- Net Riddle
- Reference
- Search