is this how a constructor is created and initialized. I am getting an error; VB does not like the "New"

what I am trying to do is to create a constructor with one argument and initialize its attribute.

Public Sub New(ByVal newProdNumber As Long)
        intProdNumber = newProdNumber
    End Sub


If this is for a custom class, VB is probably suggesting that you also have a default New constructor:

Public Sub New()
    intProdNumber = 0
End Sub

It's ok to have both.

Also remember your constructors should initialize every member of your class

thanks you very much

If this solved your problem please remember to mark this solved. Thanks.

Public Class class1  
    Shared x As Integer

    Shared Sub New()
    End Sub
End Class
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.