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

    Array Fault (vb6)

    To explain this fault, I have to post some of my code to make things clearer.
    A function I use "FillImages", fills a series of Image controls and text box's.
    Img1 thru to 4
    Text1 thru to 4

    The text is the image name "Left$(arrFileNames(i + intIndex - 1, 1), 8)"

    On double clicking the image, using a command line utility "edjpgCom.exe" comments are allowed to be added to the
    jpg header information.
    If I am on the first set of images, ie 4 of 12, using the utility doesn't cause a problem, but.
    If I scroll to the next set of images in the current array, the utility still pulls up the first set of image names ie, 1 to 4 of 12
    and adds the comment to the wrong image header.

    I can see where the problem is, but can't work out the remedy.
    Below is the "FillImages" function & "cmdNext" function & "ImgDblClick" function.
    I think the fault lies in fillImages, although the images load correctly, double clicking brings up the first array filenames.
    <pre>'Imaging
    Private Sub FillImages(intIndex As Integer)
    Dim i As Integer
    Dim fso As New Scripting.FileSystemObject
    Dim fil As Scripting.File
    imgDel
    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("img" & i).Picture = LoadPicture(strFolder & _
    "" & arrFileNames(i + intIndex - 1, 1))
    Me.Controls("Text" & i).Text = Left$(arrFileNames(i + intIndex - 1, 1), 8) & _
    " -" & "Added" & _
    " " & arrFileNames(i + intIndex - 1, 2)
    Next
    Me.txtInfo = "Images " & intIndex & " to " & _
    (intIndex + intNumberOfImages - 1) & " of " & intFileCount
    intCurIndex = intIndex
    Me.cmdFirst.Enabled = (intIndex > 1)
    Me.cmdPrev.Enabled = (intIndex > 1)
    Me.cmdNext.Enabled = (intIndex < intFileCount - intNumberOfImages + 1)
    Me.cmdLast.Enabled = (intIndex < intFileCount - intNumberOfImages + 1)
    End Sub</pre>


    <pre>'Imaging
    Private Sub cmdNext_Click()
    FillImages intCurIndex + MaxNumberOfImages
    Pdf1.Visible = True
    End Sub</pre>


    <pre>'Imaging
    Private Function imgDBLclick(i As Integer)
    Dim stAppName As String
    If arrFileNames(i, 1) = vbNullString Then
    MsgBox "No Image To Comment", vbInformation, "Information"
    Exit Function
    End If
    Me.MousePointer = vbHourglass
    stAppName = "L:mmpdfutilitiesedjpgcom.exe" & _
    " " & "L:MMPDFImage" & arrFileNames(i, 1)
    Call Shell(stAppName, 1)
    Me.MousePointer = vbDefault
    End Function</pre>


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

    Re: Array Fault (vb6)

    Ok, here's a fix I came up with, it's a little naive but does the trick (so far).
    I've attached code to each double click event for each underlying image desc text.
    My only thought is I would have liked to have created a single public function to do the same trick.
    If it is possible, to reduce this code, I'm sure it would be far more efficient.

    <pre>'Imaging
    Private Sub Img1_DblClick()
    'imgDBLclick 1
    If Me.Text1.Text = vbNullString Then MsgBox "No Image To Comment", vbInformation, "Information": Exit Sub
    Dim stAppName As String
    stAppName = "L:mmpdfutilitiesedjpgcom.exe" & " " & "L:MMPDFImage" & Left$(Text1, 8) & ".jpg"
    Call Shell(stAppName, 1)
    End Sub</pre>



    <pre>'Imaging
    Private Sub Img2_DblClick()
    'imgDBLclick 2
    If Me.Text2.Text = vbNullString Then MsgBox "No Image To Comment", vbInformation, "Information": Exit Sub
    Dim stAppName As String
    stAppName = "L:mmpdfutilitiesedjpgcom.exe" & " " & "L:MMPDFImage" & Left$(Text2, 8) & ".jpg"
    Call Shell(stAppName, 1)
    End Sub</pre>



    <pre>'Imaging
    Private Sub Img3_DblClick()
    'imgDBLclick 3
    If Me.Text3.Text = vbNullString Then MsgBox "No Image To Comment", vbInformation, "Information": Exit Sub
    Dim stAppName As String
    stAppName = "L:mmpdfutilitiesedjpgcom.exe" & " " & "L:MMPDFImage" & Left$(Text3, 8) & ".jpg"
    Call Shell(stAppName, 1)
    End Sub</pre>


    etc etc

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Array Fault (vb6)

    Private Sub imgDblClick(i As Integer)
    Dim stAppName As String

    If Me.Controls("Text" & i).Text = vbNullString Then
    MsgBox "No Image To Comment", vbInformation, "Information"
    Exit Sub
    End If

    stAppName = "L:mmpdfutilitiesedjpgcom.exe" & " " & "L:MMPDFImage" & _
    Left$(Me.Controls("Text" & i), 8) & ".jpg"
    Call Shell(stAppName, 1)
    End Sub

    Private Sub Img1_DblClick()
    imgDblClick 1
    End Sub

    etc.

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

    Re: Array Fault (vb6)

    <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>
    It was't that far off after all.

    Thanks Hans

Posting Permissions

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