Hi! I have created two userforms. The first one to allow the user to specify how many images to display in the the next userform. When this is done The second userform is started using .show.
Then however i want to run a short sub when the pictures are clicked in the second user form. But i can't make this work. I get no errors. There is just nothing hapening when i click the images. There might be a very simple solution to this since I'm very new to Visual Basic.
This is the code in the first userform that loads the images in to the next. I have edited filepaths because of security reasons. Sorry.
The second userform consists of a large amount of code-parts looking like this, but with different names for all different images.Code:Private Sub UserForm_Initialize() RowBox.Value = 1 CollumnBox.Value = 1 'Add things to boxes. You can choose up to 6 times 6 images. For i = 1 To 6 RowBox.AddItem i CollumnBox.AddItem i Next i End Sub Sub OKButton_Click() Dim i As Integer, j As Integer, k As Integer, l As Integer, o As Integer m = RowBox.Value n = CollumnBox.Value SWLTool.Width = n * 54 + 660 SWLTool.Height = m * 108 + 443 o = 1 i = 1 For j = 1 To m For k = 1 To n For l = 1 To 3 Dim myImage As MSForms.Image Set myImage = otherUserform.COntrols.Add("Forms.Image.1", "Image" & i & l) With otherUserform.COntrols("Image" & i & l) .Left = 10 + 54 * (k - 1) .Top = 18 + 108 * (j - 1) .Height = 108 .Width = 54 .PictureAlignment = 2 .PictureSizeMode = 3 .Enabled = True .MousePointer = 2 If l = 1 Then .picture = LoadPicture("filepath1" & o & ".bmp") o = o + 1 .Visible = True ElseIf l = 2 Then .picture = LoadPicture("filepath2") .Visible = False ElseIf l = 3 Then .picture = LoadPicture("filepath3") .Visible = False End If End With Next l i = i + 1 Next k Next j Unload Me otherUserform.Show End Sub
The images loads fine to the other userform but "Call Radioplacements(nn)" doesn't execute when i click them. I tried replacing that with a measge box to verify, but that wouldn't run either.Code:Public Sub Image11_Click() 'with diferent numbers in the name to cover all pictures. Call RadioPlacement(1) End Sub ... ... Private Sub Image363_Click() Call RadioPlacement(36) End Sub Private Sub RadioPlacement(x) UnitBox.Value = x End Sub
I am very thankfull for any help!
Best regards
Granefelt






Reply With Quote