|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
VB Control Array Nightmare
I have a main form
It has 2 lots of drive/dir/list boxes. The first is set to Photo Albums on load The second is set to Temp Images I have 2 frames, a workspace and an album frame. I have tried to write code so that the drive1/dir1/ default startup folder paints an array of folder icons to the album frame. I have tried to write code so that the drive2/dir2/ default startup folder paints an array of images to the workspace frame. Can anyone see any inherent problems with this code that is preventing me populate the arrays. (The albums array works in a fashion, but the label does not load, the Workspace array does not seem to work at all) I have tried my best, and am pretty sure this will be my last vb project, it is just too difficult for me. Thanks for looking. Dave URL (If your feeling brave you can download the project so you can see the problem - frmMain is the form in question.) Option Explicit Dim FolderMax As Integer, FolderCount As Integer Dim WorkSpaceMax As Integer, WorkSpaceCount As Integer Dim mfso As New FileSystemObject 'connect drives Private Sub Drive1_Change() Dir1.path = Drive1.Drive File1.path = Dir1.path End Sub 'connect drives Private Sub Dir1_Change() File1.path = Dir1.path If File1.ListCount > 0 Then File1.ListIndex = 0 End Sub 'connect drives Private Sub Drive2_Change() Dir2.path = Drive2.Drive File2.path = Dir2.path End Sub 'connect drives Private Sub Dir2_Change() File2.path = Dir2.path If File2.ListCount > 0 Then File2.ListIndex = 0 End Sub Private Sub Form_Load() 'check for main project file for all albums, if it doesnt exist, create it. Dim fso As FileSystemObject Dim strFolder As String Set fso = New FileSystemObject strFolder = "c:\Photo_Albums" If fso.FolderExists(strFolder) = False Then fso.createfolder strFolder End If Set fso = New FileSystemObject strFolder = "c:\Temp_Images" If fso.FolderExists(strFolder) = False Then fso.createfolder strFolder End If Set fso = Nothing Dir1.path = "c:\Photo_Albums" Dir2.path = "c:\Temp_Images" '************************************************* *************** 'load album array size and layout Dim i As Integer FolderMax = 20 For i = 1 To FolderMax - 1 Load imgFolder(i) imgFolder(i).Left = 120 + (i Mod 5) * 720 imgFolder(i).Top = 120 + (i \ 5) * 960 imgFolder(i).Visible = False Load lblFilename(i) lblFilename(i).Left = 120 + (i Mod 5) * 720 lblFilename(i).Top = 720 + (i \ 5) * 960 lblFilename(i).Visible = False Next i '************************************************* *************** '************************************************* *************** 'load workspace array size and layout Dim ii As Integer WorkSpaceMax = 20 For ii = 1 To WorkSpaceMax - 1 Load imgWorkspace(ii) imgWorkspace(ii).Left = 120 + (ii Mod 5) * 720 imgWorkspace(ii).Top = 120 + (ii \ 5) * 960 imgWorkspace(ii).Visible = False Load lblFilenameW(ii) lblFilenameW(ii).Left = 120 + (ii Mod 5) * 720 lblFilenameW(ii).Top = 720 + (ii \ 5) * 960 lblFilenameW(ii).Visible = False Next ii '************************************************* *************** 'button disable, delete / of files and folders cmdDelAlb.Enabled = False cmdDelImg.Enabled = False End Sub '************************************************* *************** Private Sub imgFolder_Click(Index As Integer) 'Folder Array Dim ii As Integer FolderCount = Dir1.ListCount If FolderCount > FolderMax Then FolderCount = FolderMax For ii = 0 To FolderCount - 1 ' Put the name in the label below the icon lblFilename(ii).Caption = Dir$(Dir1.List(ii)) ' Make them both visible imgFolder(ii).Visible = True lblFilename(ii).Visible = True Next ii ' Now make all the other image controls invisible For ii = FolderCount To FolderMax - 1 imgFolder(ii).Visible = False lblFilename(ii).Visible = False Next ii End Sub '************************************************* *************** '************************************************* *************** Private Sub imgWorkSpace_Click(Index As Integer) 'WorkSpace Array Dim ii As Integer WorkSpaceCount = File2.ListCount If WorkSpaceCount > WorkSpaceMax Then WorkSpaceCount = WorkSpaceMax For ii = 0 To WorkSpaceCount - 1 imgWorkspace(ii).Picture = LoadPicture(File2.List(ii)) ' Put the name in the label below the icon lblFilenameW(ii).Caption = Dir$(Dir1.List(ii)) ' Make them both visible imgWorkspace(ii).Visible = True lblFilenameW(ii).Visible = True Next ii ' Now make all the other image controls invisible For ii = WorkSpaceCount To WorkSpaceMax - 1 imgWorkspace(ii).Visible = False lblFilenameW(ii).Visible = False Next ii End Sub '************************************************* *************** |
![]() |
| Viewing: Dev Articles Community Forums > Programming > ASP Development > VB Control Array Nightmare |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|