473,323 Members | 1,589 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

I want help How I can align rectangles

I want help
How I can align rectangles differ in its tow dimensions inside big rectangle with lesser waste in area ?

for mor information
align.rar - 1.8 Kb

or:
copy this code to text file and change its extension from txt to frm and insert this form to new project:

VERSION 5.00
Begin VB.Form frmMain
Caption = "Form1"
ClientHeight = 7485
ClientLeft = 60
ClientTop = 450
ClientWidth = 8100
LinkTopic = "Form1"
ScaleHeight = 499
ScaleMode = 3 'Pixel
ScaleWidth = 540
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton cmdNest
Caption = "align "
Height = 375
Left = 6000
TabIndex = 2
Top = 6840
Width = 1815
End
Begin VB.CommandButton cmdNew
Caption = "new"
Height = 375
Left = 6000
TabIndex = 1
Top = 6240
Width = 1815
End
Begin VB.PictureBox PicTable
Appearance = 0 'Flat
BackColor = &H80000005&
ForeColor = &H80000008&
Height = 3660
Left = 6000
ScaleHeight = 242
ScaleMode = 3 'Pixel
ScaleWidth = 120
TabIndex = 0
Top = 2280
Width = 1830
End
Begin VB.Label imgDarfa
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000018&
BorderStyle = 1 'Fixed Single
Caption = "1"
BeginProperty Font
Name = "MS Sans Serif"
Size = 13.5
Charset = 178
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000040C0&
Height = 900
Index = 0
Left = 840
TabIndex = 3
Top = 1800
Width = 450
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'
Dim numDarfa As Integer

Private Sub cmdNest_Click()
'How I can align this rectangles (imgDarfa) in the big rectangle (PicTable)
Set imgDarfa(0).Container = PicTable
imgDarfa(0).Left = 0
imgDarfa(0).Top = 0
End Sub

Private Sub cmdNew_Click()
Dim i As Integer
Dim m As Integer
Dim Wd As Single
Dim Ht As Single
Dim D As Single
Dim n As Integer
'
For i = 0 To numDarfa
m = Rnd * 100
If m < 50 Then m = 1 Else m = -1
D = Rnd * 30
Ht = 60 + m * D

m = Rnd * 100
If m < 50 Then m = 1 Else m = -1
D = Rnd * 15
Wd = 30 + m * D

Set imgDarfa(i).Container = Me
imgDarfa(i).Width = Wd
imgDarfa(i).Height = Ht

'

Next i
ReArrange
End Sub

Private Sub Form_Load()
Dim i As Integer
'
numDarfa = 14
Randomize Timer
For i = 1 To numDarfa
Load imgDarfa(i)
imgDarfa(i).Visible = True
imgDarfa(i).Caption = i + 1
Next i
cmdNew_Click
End Sub
'





Private Sub ReArrange()
Dim i As Integer
For i = 0 To imgDarfa.UBound
If i <> 0 Then
imgDarfa(i).Left = imgDarfa(i - 1).Left + imgDarfa(i - 1).Width
imgDarfa(i).Top = 5
Else
imgDarfa(i).Left = 5
imgDarfa(i).Top = 5
End If
Next i

End Sub
Mar 31 '08 #1
0 1230

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Donnell Perez | last post by:
----30266114589728909 Content-Type: text/html; Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title>
8
by: lawrence | last post by:
Under the domain publicpen.com I've several dozen sites in subdiretories, such as www.publicpen.com/honenbeger. I've no trouble with any of these sites. But under one, which I put in yesterday,...
7
by: Chris | last post by:
I'm using eight links listed horizontally as a menu on my site. I'm using font-variant:small-caps and they are padded so that they mimic buttons. My gripe is with the way IE handles the focus...
9
by: Veerle | last post by:
Hi, I would like to divide the whole of my html page in 4 equal rectangles using only div tags in my html. The result should look a bit like this site:...
3
by: cai_rongxi | last post by:
Hi, Can some body share the code to find the intersection of two rectangles? Thanks in advance
0
by: Fir5tSight | last post by:
Hi All, Again I apologize for posting this topic at the wrong forum, because I don't know where else I can get help on this matter. This is about invisible lines and rectangles in a PDF file....
7
by: ddecoste | last post by:
I have a need to add a visual representation to some data in Access. I need to draw a matix of squares inside another square. I have all the data that I need in a record in Access. The data...
9
by: active | last post by:
I need a control that displays a grid of rectangles. That is, like a brick wall except the rectangles are lined up. In VB6 I used such a control (may have been called FlexGrid but I'm not...
1
by: kiranbabu | last post by:
<html> <head> <style type="text/css"> h2{color:#A02820} </style> </head> <script language=javascript>
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.