VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Space Images in Background

by Shawn M. Hershman (1 Submission)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (2 Votes)

Evenly spaces an image as many times as will fit on a form

Assumes
1) Create a picture in the form and set it's INDEX property to 0 and it's VISIBLE property to false 2) SHOW the form before calling this subroutine
Side Effects
None I'm aware of

Rate Space Images in Background

Private Sub Space_Images()
Dim PicCols As Integer
Dim PicRows As Integer
Dim HExtraSpace As Integer
Dim VExtraSpace As Integer
Dim HSpacing As Integer
Dim VSpacing As Integer
Dim i As Integer
Dim j As Integer
Dim k As Integer
On Error Resume Next
 'Calculate the appropriate spacings
 PicCols = CInt((Me.Width / picPicture(0).Width) - 0.5)
 PicRows = CInt((Me.Height / picPicture(0).Height) - 0.5)
 HExtraSpace = Me.Width - (picPicture(0).Width * PicCols)
 VExtraSpace = Me.Height - (picPicture(0).Height * PicRows)
 HSpacing = CInt((HExtraSpace / (PicCols + 1)) - 0.5)
 VSpacing = CInt((VExtraSpace / (PicRows + 1)) - 0.5)
 
 'Display the background images
 For i = 0 To PicRows - 1
 For j = 0 To PicCols - 1
  k = (PicCols * i) + j
  Load picPicture(k)
  picPicture(k).Left = (HSpacing * (j + 1)) + (picPicture(0).Width * j)
  picPicture(k).Top = (VSpacing * (i + 1)) + (picPicture(0).Height * i)
  picPicture(k).Visible = True
 Next j
 Next i
 
End Sub

Download this snippet    Add to My Saved Code

Space Images in Background Comments

No comments have been posted about Space Images in Background. Why not be the first to post a comment about Space Images in Background.

Post your comment

Subject:
Message:
0/1000 characters