onfire4JesusCollins
onfire4JesusCollins

Reputation: 219

error message on a line of code

I am getting this error message:

Warning 1 Variable declaration without an 'As' clause; type of Object assumed.

And here is the line of code that generate the error message:

Dim acceptedExtensions = New String() {".jpg", ".png", ".gif"}

Can someone help me please?

Upvotes: 1

Views: 669

Answers (2)

MarkJ
MarkJ

Reputation: 30398

Just use Option Infer, and the compiler will infer the type as String().

Option Infer On
...
Dim acceptedExtensions = New String() {".jpg", ".png", ".gif"}

The warning message indicates you have Option Strict Off. I definitely recommend always using Option Strict On to avoid all sorts of problems.

Upvotes: 0

Mark Byers
Mark Byers

Reputation: 837946

Specify the type of your variable as String():

Dim acceptedExtensions As String() = New String() {".jpg", ".png", ".gif"}

Upvotes: 6

Related Questions