Solved

Coordinates of size changed boxes

Posted on 2004-09-03
3
162 Views
Last Modified: 2010-05-02
Hi.. I have a problem about the coordinates of the form. I  draw boxes which made of line objects. Every box is 5x5. When user click on them box fill with a red color. And I get the coordinates of the boxes when user click on them.  But when I change the size of the boxes from 5x5 to 8x8, coordinates doenst match the bigger boxes. I couldnt find any any mathematical formula that gives me the new coordinates. Does any one have the same problem?
0
Comment
Question by:blacklord
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 8

Accepted Solution

by:
mladenovicz earned 250 total points
ID: 11970968
Important information is Left and Top of the box, and size (e.g. 5 or 8)

can you post some code that makes you problem?
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 11972488
Are you trying to modify one of you PAQs?
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_21111443.html

If so, then is this what you are after?

Option Explicit

Private Const boxWidth = 8 ' <--- Just change the value here

Private Sub Form_Load()
    Me.AutoRedraw = True
    Me.ScaleMode = vbPixels
   
    For i = 1 To Me.Width Step boxWidth
        Me.Line (0, i)-(Me.Width, i), , BF
    Next i
    For i = 1 To Me.Height Step boxWidth
        Me.Line (i, 1)-(i, Me.Height), , BF
    Next i
End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim cX As Integer, cY As Integer
    Dim tmpX As Integer, tmpY As Integer
   
    tmpX = Int(X / boxWidth) * boxWidth
    tmpY = Int(Y / boxWidth) * boxWidth
   
    cX = tmpX
    cY = tmpY
   
    Me.Line (cX, cY)-(cX + boxWidth, cY + boxWidth), vbRed, BF
End Sub

Regards,

Idle_Mind
0
 

Author Comment

by:blacklord
ID: 12015869
Thank you for your interest.. I figure out how to make it.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month7 days, 1 hour left to enroll

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question