Results 1 to 3 of 3
  1. #1
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Simple Function (VB6)

    <P ID="edit" class=small>(Edited by D Willett on 05-Dec-03 14:41. Found out how do do it)</P>This simple function keeps throwing type mismatch at me.
    I have tried various ways to clear the contents of 6 image controls:

    Me.Controls("img" & I).Picture = Null
    Me.Controls("img" & I).Picture = ""
    Me.Controls("img" & I).Picture = 0
    Me.Controls("img" & I).Picture = "None"
    Me.Controls("img" & I).Picture = False

    What can be causing this problem, the texts clear ok but not the image controls ?


    <pre>Private Function imgDel()

    Dim I As Integer
    Dim intIndex As Integer

    If intIndex > intFileCount - intNumberOfImages + 1 Then
    intIndex = intFileCount - intNumberOfImages + 1
    End If
    If intIndex < 1 Then
    intIndex = 1
    End If
    For I = 1 To intNumberOfImages
    Me.Controls("Text" & I).Text = ""
    Me.Controls("img" & I).Picture = (None)
    Next
    intCurIndex = intIndex
    End Function</pre>

    ================================================== ===========
    I solved it as below:
    ================================================== ===========

    <pre>Private Function imgDel()

    Dim I As Integer
    Dim intIndex As Integer
    Dim None As Property

    If intIndex > intFileCount - intNumberOfImages + 1 Then
    intIndex = intFileCount - intNumberOfImages + 1
    End If
    If intIndex < 1 Then
    intIndex = 1
    End If
    For I = 1 To intNumberOfImages
    Me.Controls("Text" & I).Text = ""
    Me.Controls("img" & I).Picture = None
    Next
    intCurIndex = intIndex

    End Function</pre>


  2. #2
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Simple Function (VB6)

    Not sure if this is what you're after Dave:

    Me.Controls("img" & I).Picture = LoadPicture("") ' pair of double quotes as argument

    but it seems to work for an image control in a userform.

    Alan

  3. #3
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Simple Function (VB6)

    Thanks Alan.
    I'll keep this just in case, but for now my version works.

Posting Permissions

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