Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / VB

How to complete your programming homework assignment

1.00/5 (1 vote)
7 Sep 2010CPOL 9.9K  
A short program that demonstrates some fundamental programming techniques that every student should understand.
The following short program demonstrates a number of fundamental programming techniques that you will probably need when attempting to complete homework assignments.

This isn't the answer to your homework assignment, but if you don't understand this program then you won't get far.

VB.NET
Public Class Form1

    Private ableToProgram As Boolean = False

    Private Sub Button1_Click(ByVal sender As System.Object, _
                              ByVal e As System.EventArgs) _
                              Handles Button1.Click
        Dim grade As String
        Dim decision As String

        While Not ableToProgram
            decision = InputBox("Do you want to cheat? (Y/N)", _
                                "Learn to Program", "Y")
            If decision.ToUpper = "Y" Then
                grade = PostAssignmentOnForums()
            Else
                grade = DoWorkYourself()
            End If
            MsgBox(String.Format("You got an {0}", grade))
        End While

        MsgBox("Good Choice!")
    End Sub

    Function PostAssignmentOnForums() As String
        ableToProgram = False
        Return "F"
    End Function

    Function DoWorkYourself() As String
        ableToProgram = True
        Return "A"
    End Function

End Class

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)