Hi
I am getting error Invalid use of new Keyword
Dim picoriginal As New PictureBox
Thanks
Hi
I am getting error Invalid use of new Keyword
Dim picoriginal As New PictureBox
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Eliana BlakeRank #1,595 · 993 reputationPosted Mar 20, 2025, 9:30 AM EDT
Hi there! It seems like you're encountering the "Invalid use of new Keyword" error in your code snippet. This issue typically arises when the "New" keyword is used inappropriately or when it's used in a context where it's not allowed.
In the snippet you provided:
The error could be occurring because the "New" keyword is being used at the declaration of the variable "picoriginal." In some programming languages, like VB.NET, you can't use the "New" keyword when declaring a variable of a reference type.
To resolve this issue, you can initialize the PictureBox object separately after declaring the variable, like this:
By doing this, you separate the declaration of the variable from the creation of the object, which should prevent the "Invalid use of new Keyword" error from occurring.
I hope this helps clarify the error you're facing. If you have any more questions or need further assistance, feel free to ask!