'初始化
Private Sub Form_Load()VScroll1.Max = Picture1.Height - Picture1.Height
HScroll1.Max = Picture1.Width - Picture1.Width
End Sub
'横向滚动
Private Sub HScroll1_Change()
Picture1.Left = -HScroll1.Value
End Sub
'纵向滚动
Private Sub VScroll1_Change()
Picture1.Top = -VScroll1.Value
End SubPrivate Sub Picture1_Click()
Picture1.Picture = LoadPicture()
If Picture1.Height > Picture2.Height Then
    VScroll1.Visible = True
Else
    VScroll1.Visible = False
End If
End Sub

解决方案 »

  1.   

    Private Sub Label1_Click()
    Dim n As String
      Picture2.AutoSize = True
      Picture2.Top = 0
      Picture2.Left = 0
      n = InputBox("Path" + Chr(10) + " D:\Big Sky.tif" + Chr(13) + " D:\Rose.bmp", , "D:\key.bmp")
      Picture2.Picture = LoadPicture(n)
      HScroll1.Visible = False
      VScroll1.Visible = False
    If Picture2.Width - Picture1.Width > 0 Then
       HScroll1.Visible = True
       'HScroll1.Enabled = True
       HScroll1.LargeChange = Int((Picture2.Width - Picture1.Width) / 10)
       HScroll1.SmallChange = Int((Picture2.Width - Picture1.Width) / 100)
    Else
       HScroll1.Visible = False
       'HScroll1.Enabled = False
    End If
    If Picture2.Height - Picture1.Height > 0 Then
       VScroll1.Visible = True
       'VScroll1.Enabled = True
       VScroll1.LargeChange = Int((Picture2.Height - Picture1.Height) / 10)
       VScroll1.SmallChange = Int((Picture2.Height - Picture1.Height) / 100)
    Else
       VScroll1.Visible = False
       'VScroll1.Enabled = False
    End If
    HScroll1.Max = Picture2.Width - Picture1.Width
    VScroll1.Max = Picture2.Height - Picture1.Height
    End Sub
    Private Sub HScroll1_Scroll()
     
     Picture2.Left = -HScroll1.Value
    End Sub
    Private Sub VScroll1_Scroll()
     
     Picture2.Top = -VScroll1.Value
    End Sub
    Private Sub HScroll1_Change() Picture2.Left = -HScroll1.Value
    End Sub
    Private Sub VScroll1_Change() Picture2.Top = -VScroll1.Value
    End Sub