I want to do a list of products wich has many properties such as price, name, id,..etc.
I made a module and create a struct product then I made a list to have all products.
The add button should add values from textfields to the list however it doesn't work. Getting error:
"An unhandled exception of type 'System.NullReferenceException' occurred in RFID.exe"
I am getting the error in this line:
Module1.newProduct.Add(product)
This is the code showing how it done and help find the mistake please.
In module1:
Public newProduct As List(Of product)
Structure product
    Public productID As Integer
    Public productName As String
    Public Category As String
    Public releaseDate As Date
    Public price As Double
    Public quantity As Integer
End Structure
In the main form, in the add button:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    If TxtPID.Text <> "" Then
        Dim product As Module1.product
        product.productID = Convert.ToInt32(TxtPID.Text)
        product.productName = TxtPName.Text
        product.Category = LCategory.Text
        product.releaseDate = TxtRDate.Text
        product.price = Convert.ToDouble(TxtPrice.Text)
        product.quantity = Convert.ToInt32(TxtQuantity.Text)
        Module1.newProduct.Add(product)
        MsgBox("Product has been added.")
    Else
        MsgBox("Enter Product ID!")
    End If
End Sub
 
    