PDA

View Full Version : Adding Scroll bar to image box in vba



princ_wns
12-13-2011, 04:18 PM
hi everyone,


after spending around a whole day i couldn't able to find any thing that how to add scroll bar to image box in vba.
please help me to find this .


thanks in advance.

prince

Admin
12-13-2011, 09:47 PM
Hi Prince,

The best I could come up with is setup a Combobox with some dimensions.

In the userform module


Const frmWidth As Single = 700
Const frmHeight As Single = 560
Private Sub ComboBox1_Change()

Dim strSize As String
Dim x

If Len(Me.ComboBox1.Value) Then
strSize = Me.ComboBox1.Value
x = Split(strSize, "x")
With Me
.Height = Application.Max(frmHeight, CLng(x(0)))
.Width = Application.Max(frmWidth, CLng(x(1)))
End With
With Me.Image1
.Top = .Top
.Left = .Left
.Width = CLng(x(1))
.Height = CLng(x(0))
End With
End If

End Sub

Private Sub UserForm_Initialize()

Dim varSize


varSize = Array("16x16", "32x32", "64x64", "160x120", "180x132", "256x192", "320x240", "320x400", _
"352x288", "400x300", "480x320", "512x342", "544x372", "640x480", "720x540", "800x600", _
"1024x768", "1280x1024")

With Me.Image1
.Picture = LoadPicture("C:\Pictures\DSC02264.jpg")
.Height = 16
.Width = 16
End With

With Me.ComboBox1
.List = varSize
.ListIndex = 0
End With

End Sub