Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Line On Circle

Greetings every1,
i want to draw a circle and a line attached to the circle, and with each step, the line must rotate on the circumference of the circle. I think a look at the attachment will make u guyz understand the problem, plz help me. I want to know how to do it mathematically. Thanx

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Line On Circle
Greetings every1,
i want to draw a circle and a line attached to the circle, and with each step, the line must rotate on the circumference of the circle. I think a look at the attachment will make u guyz understand the problem, plz help me. I want to now how to do it mathematically. Thanx

Save Circle,line
I was wondering if it was possible to keep things like Circles, and Lines that you apply with code from dissapearing after you minimize the form, or move another window in front of it.

Circle Follow Line?

Is there somebody who can help me with next question... How can i let follow a circle on a line? (see attachment)....

tnx MiSKMaN

Draw This Line On The Circle.
i want to draw the top left red line so it touches the edge of the circle.
instead of going to the middle of the circle like the other 3 lines i want it to go from (0,0) like it does, and stop the line when it hits the outside of the circle.
i dunno the maths to do this if anyone can help?

More Intersections: Line And Circle
i've looked around and found the actual formula for determining where a line and a circle cross and its a total nightmare. far to long, and way too slow to use eficiently. besides, i'm not looking for the point(s) where they cross, just if they do.

the only better way i have thought of to do it would be:

project a line out from the center of the circle the length of its radius.
make that line perpendicular to the line i'm testing, keeping one endpoint at the center of the circle.
if those lines intersect then the line i'm testing for is inside the circle, right? sounds pretty solid in theory, but i'd love a check on my logic there. i'm wondering if there is a flaw i'm not seeing. either way, isn't there a more efficient system for doing this? other than that horrible formula?


I'm trying to make sort of a pie chart. I have a circle and a line that appear when my form loads. I also have a textbox and a command button. The idea is this: a person enters a number into the textbox, and when they click the command button the figure entered in text1 is given as an angle with the line at Form_Activate, from the centre of the circle:

Private Sub Form_Activate()
Circle (1000, 1000), 1000

Line (1000, 1000)-(1000, 0)
'Line (1000, 1000)-(2000, 1000)
'Line (1000, 1000)-(0, 1000)
'Line (1000, 1000)-(1000, 2000)
End Sub

'and when they click command button:

Private Sub Command1_Click()
Line (1000, 1000)-(1000 + Text1 * 11.11, 0 + Text1 * 11.11)

End Sub

The way I had planned was by getting the X2 and Y2 coordinates of two lines, both of length 1000, for 0 degress and for 90 degress, from the centre of the circle.

These coordinates are:

0 degrees: (1000,0)
90 degrees: (2000,1000)

Then I divided 1000 by 90, which is 11.11 (Let this equal 1 degree). So if someone enters 10 in text1, the X2 coordinates of the line will move 1000 + 10 times 11.11, and the Y2 coordinates will move 10 times 11.11.

But it doesn't work. It works fine for 90 degrees, exactly, but the lines are all different lengths for different angles, apart from that.

So in a nutshell, how can I draw lines at an angle (whose size is specified in text1) with the line at Form_Activate, from the centre of the circle?

Thanks for any help!

Drawing Circle,arc, Or Line
Can anybody show me or provide links on some tutorial that explain how to draw circle, arc, or line in picturebox using VB6, including explain how or what these codes is defined. Perhaps you could explain me on next post if you can help. You help is appreicated

Can Be Draw A Curve Line From A Circle?
Hi all. I want to make a curve line, and I have think that a curve can be considerated as a part visible of a ellipse. So I have tried to create a procedure that draws an ellipse.

dim radius as double
dim bucle as long
dim x as double
dim y as double

radius = 2500

For bucle = 1 To radius
X = Sin(bucle) * radius
Y = Cos(bucle) * radius

Picture1.PSet (((Picture1.Width / 2) + (X + radius)) - radius, ((Y + radius) + Picture1.Height / 2) - radius)
Next bucle

with this. I can draw a perfect circle in the middle of a picturebox ...
but If I only want to display a cuadrant ... how I can know what are the pixels that I want to show, and the pixels that i don't have to draw.

ah ... if there is other methods to draw curve lines, please tell me

Thanks in advance

.circle And .line Drawing In Excel

I'm normally not a Excel VBA coder. I looked up Drawing, Circle, and Line in the repository and found mostly references to Shape objects being used on a worksheet. Is that my only drawing option in Excel? I was hoping for someway to put a standard picturebox on my Excel Userform.

I'm looking for the basic Circle and Line drawing methods I'm familiar with.


Line, Circle + With..end With = Deadly Combination?
I read in VB help on line and circle method and it showed a warning now to put them inside a with..end with.

Well i did that alot and found no error with that.

Interestingly, I looked up "with... end with" topic and there is no warning whatsoever regarding it's usage with line and circle method.

Can anyone explain what's happening? thanx! Just wanna put my curious mind to rest. :P

Move A Circle Along A Straight Line.
Hello everybody,

I'm playing around a bit and trying to do this, but I'm not quite getting there the way I'd like.

I'll explain. I draw a line on a picturebox. Now I want a circle to start moveing from the startpoint of the line to the end of the line at a constant speed. Now my math and physics skills are not very good.

Right now I can get it to work by defining the function of the line (f(x)=ax+b) and then incrementing either x or y but of course this way the speed at which the circle moves depends on the angle of the line.

I hope someone of you can explain in a simple way how to do it.

Thanks in advance for any feedback,

Drawing A Semi-Circle Line
Well here I am again, stumped. I've looked through API viewer and didn't even find an API that I thought would help. I need to draw a semi-circle line. It needs to be able to change the distance it goes, how high it goes, etc. Like the starting point would be the X1, the ending point would be the X2, and the highest point of the line would be the Y. Also, I need to be able to draw it ontop of a window of an external application (not anything at all todo with my project). Thank you for your time

Calculating The Angle Of A Line In A Circle
Hi all,

I've got some complicated physics equations I need to use in VB, and I need to figure out the angle of a line, from 0 to 180...

Here is a screen shot of the line:

Draw Line Or Circle In A Picture Box
I trying to pass some code in VB6 to VBA but I can find a way to access PictureBox control features like drawing a circle or a line in VBA. Is it possible? I probably need to import a reference like msvbvm60.dll (when I do it, it conflicts with the default object library loaded). Is there another way of doing this?
Thanks in advance, any help is welcome!
Best regards,
Luis Fernandes

Edited by - luisfernandes on 10/14/2003 11:09:28 AM

Delete Circle And Line From Piccturebox
i have drawn some circles and lines in a picturebox using line and circle method of picturebox control now i want to delete few of them,please help me how to dothat with source code ,its urgent please

Making A Circle SHAPE Follow A Line
ok - i've got it set so that when i press a button a line locks onto a specific part of the form - and the other locks onto where the puck(circle) is (which could be anywhere)

now i'm wondering how i could make the puck then follow that line until the end of the line

right now i have it set so that the line Begins at the specific part of the form - and the end (X2,Y2) start at the puck - but i could easily change it around if it's easier

How To Select A Line Or Circle Or Curve At Runtime
Hi. I have written some graphics code using VB 6.0. I wonder if anyone knows how I can I create codes that allows me to pick or select one of the entity that I have generated during runtime. The program create a line between two end points in the picbox. It also allows user to create a circle around the picbox. Then it allows user to create a curve (points) based equation. Finally, it allows user to generate a line based by specifying
two points using form2.

Form 1 :

Private Sub DrawCvCmd_Click()
Dim n As Single
picbox.DrawWidth = 1
For n = 0 To 100 Step 0.2
picbox.PSet (n, Sqr(n)), vbMagenta
picbox.CurrentX = 55
picbox.CurrentY = 12
picbox.Print "y = Sqr(X)"
Next n
End Sub

Private Sub drawlinecmd_Click()
picbox.DrawWidth = 1
picbox.Line (0, 0)-(100, 100)
picbox.DrawWidth = 4
picbox.PSet (0, 0), vbBlue
picbox.PSet (100, 100), vbBlue
picbox.CurrentX = 55
picbox.CurrentY = 55
picbox.Print "y = x"
End Sub

Private Sub clrcmd_Click()

End Sub

Private Sub DrawCirCmd_Click()
picbox.DrawWidth = 4
picbox.PSet (50, 50), vbBlue
picbox.DrawWidth = 1
picbox.Circle (50, 50), 50, vbRed
picbox.CurrentX = 50
picbox.CurrentY = 50
picbox.Print "Centre of Circle (50,50)"
End Sub

Private Sub EndCmd_Click()

End Sub

Private Sub Form_Load()

picbox.Scale (0, 100)-(100, 0)
picbox.DrawWidth = 2
picbox.Line (0, 0)-(0, 100), vbBlue
picbox.Line (0, 0)-(100, 0), vbBlue

End Sub

Private Sub GPt_Click()
End Sub

Private Sub SpdrwCmd_Click()
End Sub

Form 2:

Private Sub OKCmd_Click()
Form1.picbox.DrawWidth = 1
Form1.picbox.Line (x1, y1)-(x2, y2), vbBlack
Form1.picbox.CurrentX = x1
Form1.picbox.CurrentY = y1
Form1.picbox.Print "(" & x1 & "," & y1 & ")"
Form1.picbox.CurrentX = x2
Form1.picbox.CurrentY = y2
Form1.picbox.Print "(" & x2 & "," & y2 & ")"

End Sub

Problem: Assigning Name To Shape/circle/line
I am new to Vb6 but need to create lines/circles rectangles on a form.
I want to be able to reference each these lines/circles later so I can
change dimensions relative to textbox entries. I am at a loss as to how

to set a name for each line create after creating it
(x,y) r . how do I define this as eg: "circle1"
Any help would be appreciated ..thanks Stevebriz

Drawing A Line From Centre Of Circle To Circumference?

Say i've got a circle. Is there a formula i could use to draw a line from the centre of the circle to any point of its circumference? What i am doing is simulating the dashboard of a car, and this is for speedometers and stuff.

Thanks in advance

Line, Circle, Scale And PSet Methods
I'm Making a Controll similar to the Picturebox Control but with more stuff, I'm trying to add the line circle, scale etc methods to it.

The Line Method Works if you use this code

Public Sub Line(ByVal Flags As Integer, ByVal X1 As Single, ByVal Y1 As Single, ByVal X2 As Single, ByVal Y2 As Single, ByVal Color As Long)
Picture1.Line (X1, Y1)-(X2, Y2), Color
End Sub
Meaning you can call it like this
or using any other method that works with the standard line method

Does anyone know how I can do this for the PSet, Scale and Circle Methods?


[Edited by Sam Finch on 06-21-2000 at 11:55 AM]

How To Move Drawing Objects(line,circle,rectangl)

how to move,resize drawing objects(line,circle,rectangle etc.)in run time using mouse.

plz help

Line Input #1, Do I Read Ahead One Line (or Back Up One Line)
I am loading a file line by line using the LIne Input but at one point i need to look ahead at the next line to decided what to do on the current do i look ahead one line? or how do i use the line Input function and then back up? Any help would be greatly appreciated.

Shane Thomas
p.s. please email replys in addition to the reply of post too

Line By Line Text File Read And Correct Each Line
Can anyone help me create a small program or have any pointers
on pieces of code that reads a text file from folder "unfixed" then
fix the contents and then store the corrected contents
in another folder "fixed" and then move the file in folder "unfixed" to folder "old"

Details of contents.
There is a space infront of each line that should be removed.
Between the first group of numbers and the second there should be a zero for every space.
Then after the second group of numbers there should be just one space and the rest trimed off.

011531015222360000500355 3350505212004 50122
011531015222360000500363 5336305212004 6255
011531015222360000503465 2404505212004 50022
011531015222360000503463 1345205212004 50025
02153101522236 13 1503256

The @ symbol represents where a space should be.
I would like to read the file and then correct it and then
place the fixed contents in another folder with the original name.
Below is how I would like it to look.


Replacing A Line Of Text With A Blank Line, Then Delete That Line
The code below works perfect, retrieving the string of text that the user selects from the listview. Then I do bla bla bla. What I want to do is convert this so that the the user selects a string from the listview which corresponse to a string in the file. then click remove. my problem is, how do i remove a line of text from a text file? if i open for reading i cant modify the contents, if i open for writing it erases the data. and i dont want to write the data into a string, parse out the string that i don't want then rewrite the file.... that could be....not so good...

'the line that actually is in the file..
i want to remove this line...
Dim strSelected As String
strSelected = lvwAccounts.ListItems(lvwAccounts.SelectedItem.Index)

Dim objFSO As New FileSystemObject
Dim objFile As File
Dim objTS As TextStream
Dim strReadline As String
Dim strFind As String
Dim strData As String
Dim strEmail As String
Dim blnFound As Boolean

Set objFile = objFSO.GetFile(App.Path & "pop3a.txt")
Set objTS = objFile.OpenAsTextStream(ForReading)
Do Until objTS.AtEndOfStream Or blnFound = True
'reads line in file
strReadline = objTS.ReadLine
strFind = "="
strData = (InStr(1, strReadline, strFind) + 1)
strEmail = Mid(strReadline, strData)
If strEmail = lvwAccounts.SelectedItem.Text Then
frmEdit.txtEmail = strEmail
blnFound = True
End If
- Gabe

API Circle
Dear All,

I am writing a GDI graphically intensive program, which needs to draw about 6000 circles as quickly as possible. The radius is not much, it varies from about two at the most to just .5 (one pixel on the screen). I am currently achieving this using the intrinsic visual basic 6 functions such as "circle" and "pset", however, I feel that they are too slow for my requirements. Does Anyone here know of the fastest GDI way possible without using DirectX or OpenGL.

Finally, I have heard from several sources that many intrinsic visual basic functions are slow compared to there API counterparts. For example, paintpicture is ten times slower than bitblt. And the standard line command is significantly slower than the API lineto. So I was hoping that this would also be the case regarding the circle command, which is not performing as fast as I would have hoped.

I would appreciate assistance greatly, thank you in advance.

Kind Regards,

Steven Jones.

Cut A Circle?
I try to make some garphic stuff for my computer controled faceting machine, for cutting gems.

If I have a Vertical scroll to move down a circle(gem) over a line(diamond lap) and then move the circle upp again, I want to have a facet on the circle. Does anyone have som tips on how to do it?

Private Sub VScroll1_Change()
VScroll1.Max = 80
VScroll1.Min = 20
Picture1.Scale (0, 0)-(100, 100)
YY = VScroll1.Value
Picture1.Circle (50, YY), 20
Picture1.Line (100, 80)-(0, 80)
End Sub

The next step is to rotate the circle an make a new facet..... I guess it's tricky.

Thank you,
Sorry for my bad English.

I Know I Can Use Circle() But...
...I would like to do it manually by Cos() and Sin() just to figure it out. (and to draw for instance triangles and octagons)
I think I used something like this on a previous programming language to draw a circle:
(X and Y are coordinates on screen where center of circle should be, R is the size(radius) of the circle,A is the number of angles, for instance for drawing a octagon)

PSet (X + (Cos(0) * R), Y + (Sin(0) * R))
For i = 0 To 360 Step (360 / A)
Line -(X + (Cos(i) * R), Y + (Sin(i) * R))
End If

This does not become a circle though..more like a scrambled mess..
I'd appreciate any suggestions of what I am doing wrong..


Circle Help
I made a circle using the .circle function, and I need to match it with points on a line.

Not as clear as I meant it to be. How do I find every point on a circle in VB?


I am using the follwiing code:

degrees = (marks / maxMarks) * 100
degrees = (degrees / 100) * 360

With Me
Pi = 4 * Atn(1)
radius = .Height / 15
centreX = .ScaleLeft + .Width - radius - 500

centreY = .ScaleTop + radius + 400
angleOne = -2 * Pi
angletwo = -degrees * Pi / 180
.FillColor = vbRed
Circle (centreX, centreY), radius, vbBlack, angletwo, angleOne
.FillColor = &H9BF0B
Circle (centreX, centreY), radius, vbBlack, angleOne, angletwo
End With

This produces a chart showing the percentage of correct and incorrect answers on a test. The 2nd circle starts drawing from 90 degrees in the circle. How can I make it start from 0?


I have no problem drawing a single cicle on a picturebox but how do you draw several circles on a picturebox

I am using the method stated below...
An invisible circle on a picturebox:
On click on the cmd button,it will appear and the shape of the cicle will depend on the mouse down and mouse move event of the picturebox......

I am trying to make a hangman game.....When a letter is picked and it is incorrect,
I want a circle to appear(like a head) on the lines I have drawn...does anyone
know how to do this?

X,y Of A Circle
Ok here is my problem I need a algorithum or function to plot the x,y coordinates of a circles circumfence when given the radius of the circle, the x,y of the center of the circle, and the percentage around the cirlce from a given starting point. The equation is way over my head I didn't do to well in math and my highest is algebra. as you can see i didn't do to good in english either.

Um... i just forgot how to say this.... but you know... dolphins jump out of the sea and make a "part of a circle" in the air and then they land back in the water? I want to do that with an image... how?

number of circles with (rnd) color on a picturebox.

how to detect the color of each circle?

Sorry Circle Again!!!
Well now i include a image of the course... so i want that a timer starts drawing a circle in the course. But not the circle at once, as the timer keeps going, it's drawing the circle around the course of that image and when it finishes drawing the circle it shows a msgbnox saying it's complete....

please help me!!!

I know the circle code is: (x,y),raduis,color

I have seen this done before where people can take junks out of it. For instance make a pacman or only draw a half a circle. How is this done?


I have a picture box.

Im drawing a circle inside my picture box.
Is it possible to add text inside my circle? (100, 80), 10, vbRed


Circle Help

I am trying to draw letters around the circumference of a circle. ( 16 letters arranged in a circle formation like on a clock).

Instead of working out the X,Y coordinates of each letter by hand does anyone know an easy formula to work out the coordinates??

I am totally hopeless at maths!


Please Help! {Drawing Circle}
I am a new to visual basic and i need to make a simple program which i am having trouble with. I need to draw a pacman using the circle command. Each time the the circle moves to the right its mouth opens then closes (like pacman) then once it hits the width of the form the circle moves in the other direction with its mouth on the other side. I am really having trouble doing it because i have to using bolean commands. Can some please please write me the code for this program
ps. the circle(pacman) will continue moving from left to right then to right to left like a screen save
Also each time the circle moves it has to erase it self and redraw itself to the left (depending on the location)

If someone is will to help me i am very greatful ......

Circle Colour

I am using Circle (0, 0), 0.5, vbYellow, -startangle, -endangle to create a circle.

How can I change the fillcolor of the circle?


Dotted Circle
How can I draw a circle which is dotted and has a width of more than one? If you try this directly then VB always draws the circle solid regardless of the DrawStyle setting. If you try to do it by drawing concentric dotted circles each with a width of one, then the dots in each circle don't line up, so it looks rubbish. So how can I do it?

Edit: In fact what I really want to do is have a dotted circle of a width of three pixels, with the outer two pixels black, and the inner one white. But I'll start without worrying about the colour of the inner pixel.

Circle Not Visible
This is a really basic (sorry!) problem. Actually, I'm a bit ashamed of asking it, but I simply can't get my circle to appear in the centre of a picture box.
Both the form and picture box are set up in millimetres, so the pic box is
200 x 240mm in size and the scale is shown below. I just want to put a hollow circle with a 5mm radius in the centre of the pic box, but when I click the Drawchart button nothing is visible! Setting the pic's autoredraw to true has no effect.
What's going wrong?

Private Sub cmdDrawchart_Click()

frmChart.picChart.ScaleMode = 6
picht = 240
picwid = 200 'eventually we get picwid from frmDetails
frmChart.picChart.Scale (picwid / -2, picht / -2)-(picwid / 2, picht / 2)
frmChart.picChart.Circle (0, 0), vbRed, 5

End Sub

Pixels In Circle
Is there anyway to generate an array of pixels (x,y) for every point inside of a circle? for instance the array would be something like Point(1).x and Point(1).y and would contain every pixel cordinate within the circle. If this is not possible how can I calculate whether a point is in a circle or not?

Rotating Circle.
i'm making a wheel of fortune clone so i need somehelp with the 'wheel'.
1) how do i create a circle that is divided up into 20 or so different sections
2) how do i print the money TEXT on those pieces so it is sideways like in the tv show wheel.
3) how do i rotate the circle (some sort of trig function?)
4) when the wheel stops on a certain point (say 12'o clock) how do i determine what money value stopped on that marker.

thanks for any help.

Center Of A 3d Circle
hello all,
its been a while since i've posted. what im working on now is im trying to find the center of a 3d circle. i have searched the net and havn't found anything that was dumbed down enough for me to comprehend. any help or suggestions?

Fill A Circle?
is there a way to fill a circle with a color without going

me.fillstyle = vbsolid (x,y),r,Color

because i have multiple objects on the screen. and i want some to be colored in and some not.

Help In Rotating Circle
Hello. I am controlling servo motor with mscomm control. I can rotate the motor with visual basic. But i also want a visual effect in my form which rotates a circle at a specific angle regarding to how long i push the button. What must i do? Thanks for your help...

Draw Circle
It is possible to draw circle as the cell border. What I want is actually a circle to encircle the value in the cell.

Thanks for infos.

Circle Of Points
Im trying to have time move to the next point in a circle every loop. Right now ive got is doing a zig zag type thing where it move from the bottom left corner of the area to the top right, then back again... Is there a way to just get these points easier?

Copyright 2005-08, All rights reserved