Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplay the sum of the even numbers between two integers
    primarykey
    data
    text
    <p>I have a Visual Basic program that expects two integers from the user.</p> <p>I need tobe able to display the sum of the even numbers between the two integers entered by the user. If the user's entry is even, it should be included in the sum.</p> <p>I am having trouble figuring out the algorithm.</p> <p>Here is my code:</p> <pre><code>Public Class frmMain Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click Me.Close() End Sub Private Sub txtFirstNum_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtFirstNum.KeyPress ' allows the text box to accept only numbers, and the Backspace key If (e.KeyChar &lt; "0" OrElse e.KeyChar &gt; "9") AndAlso e.KeyChar &lt;&gt; ControlChars.Back Then e.Handled = True End If End Sub Private Sub txtSecondNum_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtSecondNum.KeyPress ' allows numbers and Backspace only If (e.KeyChar &lt; "0" OrElse e.KeyChar &gt; "9") AndAlso e.KeyChar &lt;&gt; ControlChars.Back Then e.Handled = True End If End Sub Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles btnDisplay.Click ' display the sum of even numbers ' declarations Dim intFirstNum As Integer Dim intSecondNum As Integer ' convert string to number with TryParse method Integer.TryParse(txtFirstNum.Text, intFirstNum) Integer.TryParse(txtSecondNum.Text, intSecondNum) ' find the even numbers If intFirstNum Mod 2 = 0 Then ElseIf intFirstNum Mod 2 = 1 Then End If ' add the even numbers ' display the result End Sub End Class </code></pre> <p>How can I fix this?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload