It’s a simple concept, but one I’ve never been taught. Can someone please explain the differences between the following 2 statements please:
Dim c as MyClass
Dim c as New MyClass
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Dim c as New MyClassis a shortcut and strictly equivalent to the following:Both are different to
Dim c as MyClass: the statement withoutNewonly declares the variable, it doesn’t assign a value. This means that the variable has a default value ofNothing.New MyClass, on the other hand, assigns a newly-created instance of that class to the variable.