Value of type '<type1>' cannot be converted to '<type2>'
A statement attempts to convert one data type to another in a way that is not defined. Possible causes of this error include the following:
A conversion specifies two data types between which no conversion exists. An example of this is a conversion from a
Boolean
value to theDate
type.An initialization of an array does not include braces (
{}
) following aNew
clause. In this case, <type2> is of the form '1-dimensional array of <type>'.
Error ID: BC30311
To correct this error
Make sure the expression can be converted to the destination data type.
If <type2> is an array, make sure the
New
clause contains both parentheses and braces following the type name. The following code illustrates correct initialization of an array.Dim anIntArray As Integer() = New Integer() {}
See also
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for