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




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()

picbox.Cls
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

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()
form3.Show
End Sub

Private Sub SpdrwCmd_Click()
Form2.Show
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 & ")"
Form2.Hide

End Sub




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
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.


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

radius = 2500
Picture1.Cls

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

Ploting A Line From A Curve?
I am looking for some help or direction on where I can learn this. An example would be best (it is easier for me to learn by example). What I need to know is how to plot a line starting from a center point of a circle that is rolling along a line or curve. I would also need the same for a square sliding along a line or curve. I have included a picture of what I would like to be able to do. I need to plot the red line.

! Draw Circle At Runtime !
Hi,

Anyone knows the code to draw a circle or a box at runtime ?
I already searched on google,

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

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

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?
Hellow...

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?

Circle,line,angle
Hi,

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

'north
Line (1000, 1000)-(1000, 0)
'east
'Line (1000, 1000)-(2000, 1000)
'west
'Line (1000, 1000)-(0, 1000)
'south
'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

.circle And .line Drawing In Excel
Hi,

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.

~T

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,
pebtos

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
Hi!
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

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 eg.with.circle
(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?
Hi,

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


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
Code:
usrExtendedPctBox.Line(0,0)-(100,100),vbWhite
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?

Thanks

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

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

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

plz help

Select Node,then Select Link,then Make The Line To Link
dear all:
when i implement it the coding which i switch to comment one..
and all can;t run oledi.
actuall i want to choose the node, then choose the link, after that when i fill the text box(txtsrc) from 1 , then to (txtdes) 2
then the line will connect from node(com pic) to node2.

that's all,..
thankxxxx

Select Node,then Select Link,then Make The Line To Link
dear all:
when i implement the source , then having problem, pls help me
to solve it.....


mail me:ahhow@yahoo.com

Runtime Select For Dbgrid?
I have added a combo box when ever I choose the data from combo box how can I reterive the selected Id will be display in dbgrid?.......

c pic

Select Controls At Runtime
Dear experts
I have problem for selecting control at the runtime,
Controls on available for picturebox container , select controls at runtime one or more. Can you give me the suggestion about this problem
With code

Best regards
P.SASIKUMAR


This function will be runtime ?

Runtime Select Statement
Hi,

How can I load a file at run time using the sql select statement.

regards,

Justus.

I Need To Select Every 4th Line
I have a list of about 2500 lines of data and have to pick every four for a select list. In other words, pick one skip three then pick the next record and so on. Is there a way you know that this can be done automatically? It would really help me out

Select Line In RTB
Hi,

I would like to select a whole line from within a rich text box, so that when I clicked on one of the lines, it selected that line.

I have a richtextbox full of strings such as the following:

Joe
Richard
Bill
Bob
Harry

Each string is on a new line. I would like some code, so that when you clicked anywhere on one of the names (e.g. Richard) it selected the whole of that name, from R to d.

Now I know I could have used a listbox, but I deliberately chose to use Richtextbox for formatting purposes.

Any help would be appreciated,

Regards,

Snowblind.

Select A Line In A RTB
Hello! All i want to know is, how can i select a SPECIFIC line? The
whole line! I mean, all i have to do is run an index number
through it and it will select that line!

Lets say if i want line 2 selected...the second line in that RTB will
become selected.... make sense? Can anybody help me?

Runtime Error -2147467259 Using Select
Greetings; In Use: Access 2000. VB6 & ADO 2.7

I have three items which I'm in need of assistance with:

1) I'm in the process of converting an Excel report to a VB6 datareport.
A sample following:


HTML Code:
SKUProduct DescriptionUnit CostQTYInStockExtended Cost
34221AIR FILTERS$1.9811$21.78
65253AMFLO$3.0021$63.00
Total Stock Value:$84.78
I'm trying to select fields for the recordset and I'm getting the following
runtime error

Error No: -2147467259;
Description: Data provider or other service returned an E_FAIL status.

The code I'm using is:


Code:
RsSelect = "SELECT ProductID, ProductDescription, format (ProductUnitCost, ""$##,##0.00"") as UnitCost, format(ProductQtyInStock, ""###,##0"") as QtyInStock, UnitCost * QtyInStock as
ExtendedValue from Products group by ProductID, ProductDescription, ProductUnitCost, ProductQtyInStock "
2) Using autonumber (long integer, random increment), most of the times
it returns a negative value for example (-1883938454).

Other than stripping the negative value when it's displayed, is there a way
of generating the key with out the negative?

3) I'm displaying a recordset in a flexgrid, how do I go abour displaying currency fields with their $ sign and decimal positions ($45.00) ?

Can someone point me in the right direction as to how to correct the code?

As usual I thank you in advance for your answers.

Donald

Create A SELECT Query At Runtime
HELP!!! This is more a SQL question, but can't find any help anywhere, so I am hoping there is a SQL savvy brain-iac out there who can lend a hand!

I have been trying find a way to create a SELECT query at runtime based on the user selecting values from five combo boxes. They must select at least one, but may select any combination or even all five. The data comes from a hierarchy of tables. My table structure can be one, two or three tables deep depending on what selection criteria they elect and may be comparing values in as many as six tables looking for a match. The SELECTed data always comes from the same two tables and will be the same fields no matter what search criteria they have elected to filter on.

Does anyone have an idea how to go about setting up this query??? I have tried using UNIONs, but the result ends up like an OR query rather than an AND showing any record that matches even one of the criteria.

I NEED HELP - PULL-EZE!

TIA,
MDS

How To Select Item In A ListView At Runtime
At runtime, i need to select a row in the listview.

If row 10 is selected, i need to programmatically select row nine and get the values out of the columns for row 9, not row 10.

Does anyone know how to do this?

For example:

My listview looks like this



1 one
2 two
3 three
4 four
5 five


If the user selects row four, I need to move the highlighted row to row 3 and return the value for row three.

How can I do this?

Creating New Case Select At Runtime
Alright here's the deal...

1)I'm making a directory watcher which watches however many directories u add into a list box.

2)From there It makes a list of links in the form of an HTML page.

3) my problem is saving the file w/ a custom name that the user can define. But how is that possible if you make the case select before hand?

4) is there a way to add this after the user has made a list, and then put the filename into a text box or something?

let me know if i need to explain more.



------------------
MooCow

Generating Runtime Select Case??
Hello everyone,

After generating an array of option buttons during runtime I am trying to manage the user's actions on them.

How do you actaully manage runtime generated controls?

I have tried to use:
CODEPrivate sub Option1(index as integer)
  
Select Case index

Case 1
 'actions
Case 2
 'different actions
.
.
.

End Select

End Sub

Defining Columns To Select At Runtime
Hello,

I am trying to write an update statement that will select a particular column during execution time. The problem is that the value of a local variable will determine the name of the column, so if the variable's value is '01' , then Col01 is selected from a table. Here's some code I have tried:

Update Table1
Set tmptblcol = TempTable2.Col+@colname

or

Update Table1
Set tmptblcol = TempTable2.[Col+@colname]

or

Update Table1
If @colname = '01'
Set tmptblcol = TempTable2.Col01
Else if @colname = '01'
Set tmptblcol = TempTable2.Col02

So far, T-SQL one cannot define column names on the fly...

Any help is appreciated.

Thanks.

How To Select A Line In A VbalGrid?
Hi there!
I have a vbalGrid in my VB 6.0 application. Once the form is loaded and the list populated with data, I want the first line to be selected by default, if any. How?

Select Line Input
ok dumb question.
i have a text file and i have a password on the first line and then the login name on the second.
how do i stick the login name in a variable. (told you it was dumb)

Select Line Word Vba
If you double click in the margin of word the entire line is selected.

I wanted to use the macro recorded to write a macro which selects the entire line. However, the macro recorder does not let me use the mouse in word.

2 questions

1) Is there a way to write a macro to select a line?
2) Why can't the mouse be used when recording a macro?

ListView Select Line
How can i select a line ?

I want it like if i was pressed the mouse on a line I do not want to have the line selected with :


VB Code:
Set ListView1.SelectedItem = ListView1.ListItems(2)ListView1.ListItems(2).Selected = True

How To Select A Line Through Code?
i want to select a line through code.

How can i?

Want To Select A Word From Line Using Right Click
I want to select a word from a line of RichTextBox using rightclick of mouse............ is there any way to do this..........


I've sleceted a word from the line of Rich TextBox but by using LEFT click of mouse n = InStrRev(txtSpellCheck.text, " ", txtSpellCheck.SelStart)
this code work fine but only with left button click
but I want to do it with righ click

Select Text By Line In Richtextbox
Hi

Should be an easy one but Im at a blank on it.

How can i select the first letter of a line in a richtextbox?

but like


VB Code:
Function SelectChar(byval nLineNumber as Long)  End Function


I want to be able to select the character by linenumber
so SelectChar(1) would select the character on the first line

Thanks

How Do I Select A Certain Line Of Text In A .txt File?
How can i select a certain line of text in a .txt file?

Say line 4

and then how do i make it select like the 4 word in that row?

so that then the text is out in a text box.

How To Select Recording Line In The Mixer
we can select recording line from the volume control of system tray, does anyone know how to select recording line in vb ?

Looking For A Line Of Code At Runtime
Is it possible to get VB to search for a specific line of code during runtime? for example, I have hundreds of lines of code. I know a specific line of it is bugging the whole thing up. I need to play through the program so that it breaks on the text I was looking for. help!

I know some of you will suggest I got to Edit/Find.... but that isn't exactly what I mean.

Create New Line At Runtime
i have the array line1() how can i add a new line to it at runtime?
this is probably really simple but i have searched and can't find the answer.

Create A Line In Runtime
how can you create a line when the program is working pluse give it the place on the forum

Copyright 2005-08 www.BigResource.com, All rights reserved