Error when 'option strict'

P

philip

Private Sub FlowLayoutPanel1_DragDrop(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.DragEventArgs) Handles
FlowLayoutPanel1.DragDrop
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
Dim fullFilenames() As String
fullFilenames = e.Data.GetData(DataFormats.FileDrop)
End If
End Sub

Line 'fullFilenames = e.Data.GetData(DataFormats.FileDrop)' give the Error
'Option Strict On disallows implicit conversions from 'Object' to
'1-dimensional array of String'
I must disable 'Option strict' to continue...

What must I change to avoid this error ?

Thanks for your attention

Philip
 
C

Chris Dunaway

GetData returns an Object. If it's really a string array, then you
need to cast it by calling DirectCast:

fullFilenames =
DirectCast(e.Data.GetData(DataFormats.FileDrop),String())
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top