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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Eliana BlakePosted Mar 20, 2025, 1:30 PM
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!