1 Replies - 232 Views - Last Post: 02 December 2017 - 11:18 AM Rate Topic: -----

#1 Swagga  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 01-December 17

im stuck trying to show an image if dropped

Posted 01 December 2017 - 05:18 PM

so heres my code
Imports System.IO

Public Class Form1
    Public Function GetFileName(path As String)
        Return System.IO.Path.GetFileName(path)
    End Function
    Private Sub ListBox1_DragDrop(sender As Object, e As DragEventArgs) Handles ListBox1.DragDrop
        Dim files() As String = e.Data.GetData(DataFormats.FileDrop)
        For Each path In files

            ListBox1.Items.Add(GetFileName(path))
            MsgBox(path)
            If GetFileName(path.EndsWith("jpg")) = True Then
                PictureBox1.Image = 
            End If

        Next
    End Sub

    Private Sub ListBox1_DragEnter(sender As Object, e As DragEventArgs) Handles ListBox1.DragEnter
        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
            e.Effect = DragDropEffects.Copy
        End If
    End Sub
End Class



im trying to for example when i drop an image that ends with the .jpg extention it gonna show in the picturebox but i cant get past what im gonna type in the picturebox1.time = i always get error please help

i mean picturebox1.image = dont know how to edit post yet

This post has been edited by andrewsw: 02 December 2017 - 11:23 AM
Reason for edit:: removed 'help' from topic title


Is This A Good Question/Topic? 0
  • +

Replies To: im stuck trying to show an image if dropped

#2 andrewsw  Icon User is online

  • blow up my boots
  • member icon

Reputation: 6442
  • View blog
  • Posts: 26,057
  • Joined: 12-December 12

Re: im stuck trying to show an image if dropped

Posted 02 December 2017 - 11:18 AM

I'm not sure what your self-quote was in aide of (I have removed it), if you have something further to add press the Reply button further down the page.

This If GetFileName(path.EndsWith("jpg")) = True Then is wrong and should be If GetFileName(path).EndsWith("jpg") = True Then (although you can drop the '= True').

I searched "vb.net picturebox image" and the first result is suggesting:

Me.myPictureBox.Image = Bitmap.FromFile(ofd.FileName)

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1