Imports System.IO
Imports System.Windows.Forms.UserControl
Public Class galery
Private Sub galery_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim strFileSize As String = ""
Dim di As New IO.DirectoryInfo("C:\Documents and Settings\RKRRKAN\My Documents\Downloads\TestExcel2\TestExcel2\chihuhua")
Dim aryFi As IO.FileInfo() = di.GetFiles("*.jpg")
Dim fi As IO.FileInfo
Dim j As Integer
j = 0
For Each fi In aryFi
j = j + 1
Next
Dim test(j) As PictureBox
Dim Blue(j) As Label
Dim i As Integer
i = 0
Dim h As Integer
h = 1
For Each fi In aryFi
' strFileSize = (Math.Round(fi.Length / 1024)).ToString()
test(i) = New PictureBox
test(i).BackgroundImage = Image.FromFile("C:\Documents and Settings\My Documents\Downloads\TestExcel2\chihuhua\" & fi.Name)
test(i).BackgroundImageLayout = ImageLayout.Stretch
test(i).Width = 100
test(i).Height = 100
test(i).Top = 373
test(i).Left = 220
test(i).Location = New Point(69, 156 + h)
test(i).Visible = True
test(i).Name = "test" & i
Dim str As String
str = System.IO.Path.GetFileNameWithoutExtension("C:\Documents and Settings\My Documents\Downloads\TestExcel2\chihuhua\" & fi.Name)
Blue(i) = New Label
Blue(i).Name = "caption" & i
Blue(i).Text = str
Blue(i).Location = New Point(180, 156 + h)
Blue(i).BackColor = Color.Black
Blue(i).ForeColor = Color.DarkOrange
Blue(i).Visible = True
Me.Controls.Add(test(i))
Me.Controls.Add(Blue(i))
i = i + 1
h = h + 100
' MsgBox(fi.Name)
Next
' MsgBox(i)
End Sub
End Class