Results 1 to 4 of 4

Thread: Not image found

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Not image found

    I have problem here, When the image not found, then I want to show Image is not Available. But When the image not available is shown, I unable to clear that image before another image is shown. How to clear this?
    Code:
    Private Sub ListView3_ItemClick(ByVal item As MSComctlLib.ListItem)
       
       Pesttable.MoveFirst
       Pesttable.Move CLng(item.Index - 1)
        sTarikh = item.Text
        Command21.Enabled = True
        Command22.Enabled = True
        Form18.getID = Pesttable.Fields("id").Value
       Text21.Text = Pesttable.Fields("Nama Perosak").Value & ""
       Text23.Text = Pesttable.Fields("Nama Sintifik").Value & ""
       Text24.Text = Pesttable.Fields("Tanda serangan").Value & ""
        Picture2.Cls
        Picture2.AutoRedraw = True
        Picture2.ScaleMode = vbPixels
        On Error GoTo error3:
        Picture2.PaintPicture LoadPicture(Pesttable.Fields("Gambar")), 0, 0, 200, 200
        Exit Sub
    error3:
        If Err.Number = 481 Then
        Dim strImagePath As String
        strImagePath = App.Path & "\ancaman padi\NoImage.gif"
        Picture2.Picture = LoadPicture(strImagePath)
        Picture2.AutoRedraw = False
        Picture2.Cls
        Exit Sub
        End If
    End Sub

  2. #2
    Addicted Member
    Join Date
    Jul 2007
    Posts
    146

    Re: Not image found

    Quote Originally Posted by matrik02
    vb Code:
    1. error3:
    2.     If Err.Number = 481 Then
    3.     Dim strImagePath As String
    4.     strImagePath = App.Path & "\ancaman padi\NoImage.gif"
    5.     Picture2.Picture = LoadPicture(strImagePath)
    6.     Picture2.AutoRedraw = False
    7.     Picture2.Cls
    8.     Exit Sub
    9.     End If
    10. End Sub
    This images will never show because you clear the picturebox (line 7) right after you've loaded the image.
    Jottum™
    XpVistaControls , (transparent) usercontrols for XP, Vista and 7 with W2K legacy support.

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Not image found

    vb Code:
    1. picture2.picture = loadpicture()
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  4. #4
    Addicted Member
    Join Date
    Jul 2007
    Posts
    146

    Re: Not image found

    Quote Originally Posted by westconn1
    vb Code:
    1. picture2.picture = loadpicture()
    You are right of course, my bad.
    Jottum™
    XpVistaControls , (transparent) usercontrols for XP, Vista and 7 with W2K legacy support.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width