Error when 'option strict'

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • philip

    Error when 'option strict'

    Private Sub FlowLayoutPanel 1_DragDrop(ByVa l sender As System.Object,
    ByVal e As System.Windows. Forms.DragEvent Args) Handles
    FlowLayoutPanel 1.DragDrop
    If e.Data.GetDataP resent(DataForm ats.FileDrop) Then
    Dim fullFilenames() As String
    fullFilenames = e.Data.GetData( DataFormats.Fil eDrop)
    End If
    End Sub

    Line 'fullFilenames = e.Data.GetData( DataFormats.Fil eDrop)' 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


  • Chris Dunaway

    #2
    Re: Error when 'option strict'

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

    fullFilenames =
    DirectCast(e.Da ta.GetData(Data Formats.FileDro p),String())

    Comment

    • philip

      #3
      Re: Error when 'option strict'

      Perfect !

      Thanks sincerely. Option is again 'strict' without error. I'm happy !

      "Chris Dunaway" <dunawayc@gmail .com> a écrit dans le message de news:
      1139321282.3657 67.285450@g47g2 00...legr oups.com...[color=blue]
      > GetData returns an Object. If it's really a string array, then you
      > need to cast it by calling DirectCast:
      >
      > fullFilenames =
      > DirectCast(e.Da ta.GetData(Data Formats.FileDro p),String())
      >[/color]


      Comment

      Working...