Quantcast
Viewing all articles
Browse latest Browse all 15785

Problem with my program

I am trying to create a program that would function as a "shopping list". I have completed all the code and setting it up and what not but when I try and run the program it will not run. I have 0 errors in my code and it will not debug either. There are two programs I am having this problem with. Here is the code for both of the programs.
PROGRAM 1:
Code:

Public Class Form1
    Dim Item As String = txtAdd.Text
    Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        Item = Me.txtAdd.Text
        Me.lstItems.Items.Add(Item)
    End Sub
    Private Sub btnMoveToList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMoveToList.Click
        Me.lstItems.Items.Remove(Item)
        Me.lstList.Items.Add(Item)
    End Sub
Private Sub btnMoveToItems_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMoveToItems.Click
    Me.lstList.Items.Remove(Item)
    Me.lstItems.Items.Add(Item)
End Sub
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
    Me.lstItems.Items.Remove(Item)
End Sub
End Class

PROGRAM 2:
Code:

Public Class Form1
    Dim total As Double
    Dim Cost As Double = Me.txtCost.Text
    Dim Number As Integer = Me.txtNumber.Text


    Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
        total = (Cost * Number)

        If Int32.TryParse(Me.txtCost.Text, Me.txtNumber.Text) Then
            MessageBox.Show("The total cost of your items is:" & total)
        Else
            MessageBox.Show("Enter correct numeric values")
        End If
    End Sub

    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
        Application.Exit()
    End Sub
End Class

I am receiving a pop up window that says "An error occurred creating the form. See Exception.InnerException for details. The error is: Object reference not set to an instance of an object."

Viewing all articles
Browse latest Browse all 15785

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>