visual basic

posted by .

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 -

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

  • visual basic -

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

Respond to this Question

First Name
School Subject
Your Answer

Similar Questions

  1. visual basic

    here is my source code for my program im trying to convert 10 units from furlong to meters the answer is supposed to be 2011.68 meters i keep getting 2000. I know if i cant get this right the rest of the conversion will give the wrong …
  2. programming

    I am supposed to modify this program so it begins by asking the user for the number of values. The program then uses a loop to read the specified number of values and then display their average. program is below that i worked on in …
  3. programming

    write a program that maintains two parallel arrays. after th arrays have been loaded the program should behave as a login screen prompting for username and password. the program should respond three output messages. if username does …
  4. visual basic

    Im trying to get this program to average three number having a problem the sample nmubers im using are 6 6 2 average supposed to be 4.6667 but im just geting .6667 I think it has something to do with my s=value(i) not sure what i need …
  5. visual basic

    Program that i am having trouble with having hard time how to figure out to assign non-zero digit to a variable! Create a variable first as integer  Assign first non‐zero digit of your V‐number to the variable first  …
  6. Programming

    Write a program that allows the user to display a budget as a pie chart. After the user enters numbers into the four text boxes a presses the button, the pie chart should be displayed. When I push the button for my code it does not …
  7. Visual Basic

    what does IntTemp and IntRem mean? and whats wrong with my code, i don't know whats wrong with it... Code below: Dim intNum As Integer 'the numderator is read as a whole number. Dim intDenom As Integer 'the denominator is read as a
  8. Programming (Visual Basic)

    Im seem to be having trouble with this Exercise. Would you mind helping me please?
  9. comptuer programming

    i need help with my code i keep comin up with errors in basic Dim Firstname as string Dim Lastname as string Dim Empnum As Integer Dim HourRate As Integer Dim Hours As Integer Dim Tools As Integer Dim Total As Integer Dim Netpay As …
  10. Visual Basic

    how to use formula b=p (1+r)^n, to calculate annual interests for a savings account in visual basic project This is my code so far>>>>>>>>>>>>>> Option Explicit On Option Strict On Option Infer …

More Similar Questions