Results 1 to 9 of 9

Thread: VB6 - Coordinates of the center of a given circle?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2012
    Posts
    290

    VB6 - Coordinates of the center of a given circle?

    I want to draw like a small cross just in the center of the circle (shape).
    How can I get the coordinates of the circle?
    Do you recommend to use other different kind of circle? (I mean, not shape control).

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: VB6 - Coordinates of the center of a given circle?

    Try something like this:
    Code:
    Option Explicit
    
    Private Sub Form_Click()
    Dim centerX As Single
    Dim centerY As Single
    Dim X1 As Single
    Dim X2 As Single
    Dim Y1 As Single
    Dim Y2 As Single
    
        Me.Cls
        
        centerX = Shape1.Left + Shape1.Width / 2
        centerY = Shape1.Top + Shape1.Height / 2
        
        X1 = centerX - 100
        X2 = centerX + 100
        Y1 = centerY
        Y2 = centerY
        
        Me.Line (X1, Y1)-(X2, Y2)
        
        X1 = centerX
        X2 = centerX
        Y1 = centerY - 100
        Y2 = centerY + 100
        
        Me.Line (X1, Y1)-(X2, Y2)
    
    End Sub

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2012
    Posts
    290

    Re: VB6 - Coordinates of the center of a given circle?

    Just perfect Rhino, thanks.

    The next thing I want to do is to draw automatically a straight line from the center of the circle to the circle, given a specific angle (from 0 to 359).

  4. #4
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: VB6 - Coordinates of the center of a given circle?

    You will need to put some effort on your end... What you will need is calculate coords for the second point using few math functions.
    You may search forum - I'm sure there samples already posted.

  5. #5
    Frenzied Member
    Join Date
    Mar 2008
    Posts
    1,210

    Re: VB6 - Coordinates of the center of a given circle?

    Please check-out the Circle Method in vbhelp...

  6. #6

  7. #7
    Frenzied Member
    Join Date
    Mar 2008
    Posts
    1,210

    Re: VB6 - Coordinates of the center of a given circle?

    I thought you had already drawn the cross in the centre!
    ...

  8. #8

  9. #9
    Frenzied Member
    Join Date
    Mar 2008
    Posts
    1,210

    Re: VB6 - Coordinates of the center of a given circle?

    I thought the latest question from the OP was;
    > I want to do is to draw ... a straight line from the center of the circle to the circle, given a specific angle

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width