View Single Post
Old 02-02-2009, 22:40
Posts: n/a

I copied and pasted this code directly but there was no confirmation in the original post that indicated it works or that I am using it correctly. I'm just learning vba and my previous experience in programming is limited but I am a quick study at most things.

Looking through the docs on everything in this code, I cant seem to wrap my head around what "ByVal folder as String" means. I do not see "folder" set anywhere and "folder = whatever" dosent do anything.

When I run this code it does nothing and the locals window shows no values.
I get what it is supposed to do and I'm sure it is somethin I'm doing wrong, can someone point it out?

Sub FillPage(mp As MSForms.MultiPage, ByVal folder As String)
   Const imgWidth! = 72, imgHeight! = 72, pad! = 3, labelHeight! = 25
   Dim i&, p As MSForms.Page, file$, x!, y!, pic As StdPicture
   On Error Resume Next
   If Right$(folder, 1) <> "\" Then folder = folder & "\"
   i = InStrRev(Left$(folder, Len(folder) - 1), "\")
   Set p = mp.Pages.Add(, Left$(folder, 3) & "...\" & Mid$(folder, i + 1, Len(folder) - i))
   file = Dir(folder & "*")
   x = pad: y = pad
   Do While Len(file)
      Set pic = Nothing
      Set pic = LoadPicture(folder & file)
      If Not pic Is Nothing Then
         With p.Controls.Add("Forms.Image.1")
            .Move x, y, imgWidth, imgHeight
            .BorderStyle = fmBorderStyleNone
            .Picture = pic
         End With
         With p.Controls.Add("Forms.Label.1")
            .Move x, y + imgHeight, imgWidth, labelHeight
            .Text = file
            .ControlTipText = file
         End With
         x = x + pad + imgWidth
         If x + imgWidth > p.InsideWidth Then
            x = pad
            y = y + imgHeight + labelHeight + pad
         End If
      End If
      file = Dir()
   p.ScrollHeight = p.InsideHeight
   p.ScrollBars = IIf(p.ScrollHeight > p.InsideHeight, fmScrollBarsVertical, fmScrollBarsNone)
   End Sub
Reply With Quote