Tracker
 ASP PHP JavaScripts MySQL MS Access MSSQL VISUAL BASIC Subjects/Titles Post Text/Content
HOME    TRACKER    Visual Basic

# Y Value Of A Line At A Specific Point

## say i have a line called line1 and it has its positions:.x1 = 100.y1 = 1000.x2 = 2000.y2 = 3000this makes a diagonal line. is there a formula to get the y position that line1 intersects at say x = 500?if you don't know what i mean tell me and i will post a picturei have tried to come up with a formula myself but failed so i was wondering if any of you guys could helpthanks

Making A Line Graph 1 Point Instead Of 2 Point???
Hi

I have a line graph which appears in 2 point. The MSChart property pages are of no help in making this line 1 point(as the line is created by code) so how can I code it?

Thanks

Draw A Line From Point A To Point B
Sound easy right...........how about that I need to do it on coordinate plane where X-axis is 50 and Y-axis is 50 (i thought about using my form's X and Y, but scale them so that if A (5;6) then it will display a point on form maybe....A(500;600) or whatever, but what formula can I use to scale that....i tried lots of stuff...none works.....basically all I need is to draw a line from A to B and use my form as coordinate plane, but scale it so that x = 5 and x = 10 have a visible difference....if i plug those Xs onto my form right now, then x = 5 and x = 30 don't have any visible difference at all (line will move maybe like a fraction of a milimeter (less then a 1/16 of an inch), but I need is that if x = 5 and x = 6 then it has difference about 5 milimeters on the form (line will move like 5 mm so that change in position of a line will be visible)
I hope that won't confuse you........Thank You

Cut The Image From Specific Point
Hi All

I have one scaned document in that document there is at each specific point "hr" is printed.

now what i want i want make seprate image between one "hr" to another "hr".

any one can help out in this probs

Starting At A Specific Point Within A Sub
Ok i have a program, at the end of the loop it asks if you would like to start the loop over.. If i say yes how do i make it start over at a specific point within the loop?

Thank you

I'm using the code supplied in another post to add hyperlinks to my Index Worksheet. Thanks for that one !!

These links goto PDF files in the same directory.
Col 1 is the base filename, Col 3 changes as the file is revised. An "n" seperates the basename from the revision.
ex. 12345n1.pdf (1st rev) vs 12345n3.pdf (3rd rev)

When the Index Worksheet advances revision (col 3), I will re-run the macro so that the new hyperlink points to the latest revision PDF, makes sense I hope

My problem is:
I can't seem to get this VB script to begin at Row8, Col1 and blast down from there Everything above Row8 is Header Information that won't need hyperlinks. What am I doing wrong ?

Code:
'Application.ScreenUpdating = False
Dim rw As Long
Dim OmsPath As String
Dim OmsFile As String
Dim Cl1 As Integer
Dim Cl3 As Integer

Cl1 = 1 'Index Column
Cl3 = 3 'Oms Revision
OmsPath = ThisWorkbook.Path & ""
For rw = 1 To Cells(Rows.Count, Cl1).End(xlUp).Row
If Cells(rw, Cl1) <> "" Then
OmsFile = OmsPath & Cells(rw, Cl1) & "n" & Cells(rw, Cl3) & ".pdf"

End If
Next
End Sub

A Function To Point To Specific Form
I have 3 forms, frmMain, frmStatus, frmWhatever

When I
Code:
PointForm(2).Show
, it show up frmStatus, because there's a function like this:

Code:
Private Function PointForm(Item As Integer) As Form
Select Case Item
Case 1: PointForm = frmMain
Case 2: PointForm = frmStatus
Case 3: PointForm = frmWhatever
End Select
End Function
The function above obviously doesn't work, but it's something i wanna do, a function that tells which form. Erm. is that possible?

Reading From Specific Point In File
Hi, i was just wondering if there is a faster way to do this:

I am inputting one big TXT file that gets to 100 kb and more sometimes every 5 seconds and then i ignore all begging, because i usually only want like the last 5 letters of the file. So my quesstion is how can i make the application only input everything behind a number of characters that i specify

How Can You Add A Character At A Specific Point In A String?
Anyone know?
Say I wanted to add a vbcrlf after 124, 344 and 567 characters in a string that is 800 characters long..

How To Point To A Specific Thing In A Listbox? Help
Hi
how do you point to a specific item in a listbox. i.e. io wanna say if the first thing in one list is less then the second in another list

Read File From Specific Point To The End??
I am attempting to read a file and write what I read to the end of another file. My problem is that I do not want to read the first part of the file I am reading. I need to find a "keyword" which tells me where to start reading and writing the information to the other file. Here is my code.... this code opens one file for reading and then writes the whole file to the end of the other file?

Do I need to do this line by line to accomplish what i need? The problem is the file i am reading is an extremely long html file.

dim fso as new FileSystemObject
Dim file as file
dim filetocopy as file
dim textstream as textstream
dim newTextstream as textstream

Set file = fso.GetFile(MyfilePath.html)
set filetocopy = fso.getfile(MyFileToCopy.html)
set textstream = file.OpenAsTextStream(ForAppending)
textstream.close
newtextstream.close
set file = nothing
set fso = nothing

Any suggestions

Thanks,

M

Finding A DLL With A Specific Entry Point
I have inherited a VB6 App. that calls a DLL using loads of different Entry Points.
Most of the Entry Points work fine. However, when calling the DLL using an entry point that doesn't work, I get
"Run Time Error '453';
Can't find DLL Entry Point EnableManualWrapup in antapi2"

I have found loads of ANTAPI2 DLL's on the various drives I have access to. Is there a bit of software that will tell me what entry points each DLL has ??

Adding Data To A File At A Specific Point
Hi folks,

Here's what I want to do:

I have a file full of data. I need to make a copy of that file, open the file and then search through it looking for a specific string. Once I reach that string I need to add some new data at that point in the file and then read in the rest of the original file. If everything goes to plan I need to delete the original file and change the name of the copy to the original filename. Has anyone got a good example of something similar that I could have a look at?

Below is some existing code which I could perhaps manipulate to do what I want:

strFileName = BackSlash(pstrDataDirectory) & pstrFileNameNoPath & ".PRT" ' pstrFileNameNoPath holds the name of the file I need to edit, so I need to copy this into a new file perhaps line by line, so that I can add in the new data

Set f = New FileSystemObject
Set t = f.OpenTextFile(strFileName)

booOK = False
Do
strline = t.ReadLine ' search for the line in the output file containing "final settings"
booOK = InStr(strline, "FINAL SETTINGS") > 0 And t.Line > 10
Loop Until booOK Or t.AtEndOfStream

If booOK Then
booOK = False

' I need to add some data into the file here

Do
strline = t.ReadLine ' look for the last line before statistics for each link begin
booOK = InStr(strline, "(PCU) (PCU)") > 0
Loop Until booOK Or t.AtEndOfStream

' then add some more data in here

thanks for looking

Howler

Can I Send A Click To A Specific Point On A Form?
I've got this dumb form that minimizes to the sys tray but when I restore it, for some reason it doesn't completely get the focus until I click the form once even though it appears to have it...I finally got it working correctly by using the SetWindowPos api...but alas athough it works on my Win98 system it doesn't correct the problem on WinNT systems.....so I was wondering if there was anything similar to SendKeys that would allow me to send a MouseClick to make the dang thing happy?:wall:

How To Make The Mouse Point To A Specific Color?
Can someone give me a code where it makes me mouse point automatically at a specific color, or it could be pixel too. So if u know anything about this, plz help.

Word Automation - Insert A File At A Specific Point
I want to insert a Word template into a Word document at a specific point in the document.
(I'm creating a document from sub documents that are included depending on certain conditions)
When I do this it wipes out the rest of the document!

Does anyone have a method to do this:

Find a marker in the main document that indicates where to insert files
remove the marker
insert required files

Mac

Embedding An Attachment At A Specific Point In Notes Mail
Can anyone tell me how I embed an attachment at a specific point in a pre-drafted lotus notes email that includes graphics etc. I want to attach an excel file about half way down an e-mail?

David

How Can I Read Only One Line Or Specific Line Of A Text File
How can i read only one line or specific line of a text file?

Whats The Fastest Way To Insert Text At A Specific Point In A String?
Thisisaverylongstring
How can I insert the word 'THE' at position 9 in this string so it looks like ThisisaveTHErylongstring

Is the fastest way 'newString = left(string, position) & theInsertString & right(string, len(string) - position)

or is there a faster way?

Line Intersection Point
i need to determine the point where 2 lines intersect, and i'd also like to learn how to determine if a point is on the inside of an irregular polygon. if any of it requires anything invlovling slope i'm gonna need a refresher on that too.

help me somebody please??!! it's been way too long since i've taken a math class...

Distance Between Point And Line In 3D
The following will return the distance between a line and a point in two dimensions.

Code:
Private Function DistToSegment(ByVal px As Double, ByVal py _
As Double, ByVal X1 As Double, ByVal Y1 As Double, _
ByVal X2 As Double, ByVal Y2 As Double) As Double
' distance between a line segment and a point
Dim X As Double
Dim Y As Double
Dim B As Double
Dim M As Double
Dim BP As Double
Dim MP As Double

If (X1 = px And Y1 = py) Or (X2 = px And Y2 = py) Then ' point is coincident
DistToSegment = 0#
ElseIf X1 = X2 And Y1 = Y2 Then ' is point not line
DistToSegment = Sqr((X1 - px) ^ 2 + (Y1 - py) ^ 2)
ElseIf X1 = X2 Then ' line is vertical
DistToSegment = Abs(X1 - px)
ElseIf Y1 = Y2 Then ' line is horizontal
DistToSegment = Abs(Y1 - py)
Else
M = (Y1 - Y2) / (X1 - X2)
B = Y1 - M * X1 ' (OR b = y2 - m * x2)
' slope of perpendicular line is -1 / m
MP = -1# / M
BP = py - MP * px
' intersection
X = (BP - B) / (M - MP)
Y = M * X + B
' distance to line
DistToSegment = Sqr((X - px) ^ 2 + (Y - py) ^ 2)
End If
End Function
What I need is to determine the distance between a point and a line in 3 dimensions. The line is to be defined as a xyz point and an ijk vector. Any help appreciated.

Parsing A Line... From Point X To The End?
Hello,

Is there an easy way to parse from one point of a line on? I've tried this

The Line would be something like

FirebirdX said: !online BobJones

Code:
X = InStr(1, lastline, "!online ", vbTextCompare)
Y = InStr(1, lastline, vbCrLf, vbTextCompare)
onlinecheck = Mid\$(lastline, X + 8, Y - X - 8)
MsgBox (onlinecheck)

However, it does not work.. Any help?

How Close Is A Point To A Line?
I have a point on the form with X and Y coordinates, and a Line1 with its XY coordinates. What im trying to figure out is how to determine how far the point is from the line...
Actually the line represents a bullet and the point is enemy. I am determining an ideal slope for the bullet to hit the enemy, and then i am modifying the slope so that its not 100% precise always. I need to be able to detect if the dot is still a reasonable distance from the line and the enemy was hit.

I didnt have too much luck so far... any of you guys ever did this ? Or have any ideas ?

thank you

Splitting Line At Certain Point Before...
how can i split a line at the last "A" before 20 characters of the line and keep doing it untill the end of the string?

Gradient Of 2 Point, (along A Line)
Hi,
I have tried to use the getpixel alone a drawn line without sucess
My intention was draw a line and get the coordinate of the two point and run through every pixel on the shortest path between this two point
This might be simple or horribly difficult, i am not sure...here's my code
=======================
Sub linemove(counter, colorcode, colorcode2, Picture1, x0, y0, Picture2, g)
g = (x0 - x1) / (y0 - y1)
Dim tempx As Double
Dim tempy As Double
Dim xi As Double
Dim yi As Double
Dim i As Long
'start before the first point
xi = x0 - 1
yi = y0 - 1
'caculate out the increment of x0 and y0
tempx = g * y0
tempy = x0 / g
'here's the part, i move reader alone the longest distance coordinate
'and assume eventually it will get all the points alone the line
If y1 - y0 > x1 - x0 Then
For i = y0 To y1
xi = xi + tempx
yi = yi + tempy
If CInt(xi) = x0 Then
pix = GetPixel(Picture2.hdc, CInt(xi), CInt(yi))
'this is my another method that takes in coordinate and draw a line
'with the same angle as the original one
Call scan_col(counter, colorcode, colorcode2, Picture1, CInt(xi),_ CInt(yi))
End If
Next
End If
If y1 - y0 < x1 - x0 Then
For i = x0 To x1
xi = xi + tempx
yi = yi + tempy
If CInt(yi) = y0 Then
pix = GetPixel(Picture2.hdc, CInt(xi), CInt(yi))
'this is my another method that takes in coordinate and draw a line
'with the same angle as the original one
Call scan_col(counter, colorcode, colorcode2, Picture1, CInt(xi),_
CInt(yi))
End If
Next
End If
End Sub
================================
i am sure this is not correct and the rest of the part was working withou these line....... is there a way to do this? I have been flipping through my math text book without even a hint...... plz help

Finding If A Point Is On A Line
Given 2 points in pixels. I want to be able to calculate if a point is on the line.

I know that ax+bx+c=0 and am trying to make use of that. If that would turn out to be zero then it is on the line. for more information ax+by+c is the same as y=(a/b)x - c.

So the problem I am having is given the 2 points making an equation of the line so that I can plug in a value for x in the equation and for y so that I could test the outcome. If it is zero it is on the line otherwise it is not. Any suggestions would be much appreciated.

Plotting Point On Line Graph
This should be a challenge, because I really don't think it can be done...but need verification from the pros. I have created a line graph in VB using MSChart, that is all fine. BUT the user wants just 1 point plotted on it. Not all the points, just 1 point. Is it possible to give the x,y and have a point draw onto the line???? I can't even do it in Excel, but I am not genius. This would be totally cool...
Thanks

Distance Between A Point And A Line In 3D, Urgent
The following will return the distance between a line and a point in two dimensions.

Code:Private Function DistToSegment(ByVal px As Double, ByVal py _
As Double, ByVal X1 As Double, ByVal Y1 As Double, _
ByVal X2 As Double, ByVal Y2 As Double) As Double
' distance between a line segment and a point
Dim X As Double
Dim Y As Double
Dim B As Double
Dim M As Double
Dim BP As Double
Dim MP As Double

If (X1 = px And Y1 = py) Or (X2 = px And Y2 = py) Then ' point is coincident
DistToSegment = 0#
ElseIf X1 = X2 And Y1 = Y2 Then ' is point not line
DistToSegment = Sqr((X1 - px) ^ 2 + (Y1 - py) ^ 2)
ElseIf X1 = X2 Then ' line is vertical
DistToSegment = Abs(X1 - px)
ElseIf Y1 = Y2 Then ' line is horizontal
DistToSegment = Abs(Y1 - py)
Else
M = (Y1 - Y2) / (X1 - X2)
B = Y1 - M * X1 ' (OR b = y2 - m * x2)
' slope of perpendicular line is -1 / m
MP = -1# / M
BP = py - MP * px
' intersection
X = (BP - B) / (M - MP)
Y = M * X + B
' distance to line
DistToSegment = Sqr((X - px) ^ 2 + (Y - py) ^ 2)
End If
End Function

What I need is to determine the distance between a point and a line in 3 dimensions. The line is to be defined as a xyz point and an ijk vector. Any help appreciated.

Edited by - waits77 on 9/11/2004 1:11:06 PM

How To Draw Point And Line(any Built-in Function?)
Dear All,

On a form, I have an Image control. I have loaded the picture in this Image control.

I have to draw some points on this and then join these points so that a line is drawn( means to draw a line that passes through these points.)

How can I draw a point and line. What's the built-in function for these.

Regards,

Co-ordinates Of A Point On A Line [resolved By Beachbum]
I've got a line (control) on a form

The line can be anywhere and at any angle. ie x1 can be > or < x2 and y1 can be > or < y2.

I want to calculate the co-ordinates of a point on the line 1/4 of the way along from the x1,y1 end.

I reckon the easiest way is to convert to polar co-ordinates and back again.

any other suggestions?

Shortest Distance Between A Point And A Line Segment In 2D
I'm having one of those brain fart days. (Lack of sleep on a Friday and all that.)

Could anyone please help by sending in a nice and simple algorithm for determining the shortest distance between a point (px,py) and a line segment(x1,y1)-(x2,y2)? Thanks.

P.S. I'm actually coding in Python (for which there is no board here ) and just need the algorithm, so try not to tell me about any neat classes or libraries.

URGENT : Draw A Line With A Color An Reread With Point(X,Y)
Hi friends

i have got a problem drawing a line with a color and reread it with Point(X,Y), my part of the vb code as follows

VB Code:
' assigning line color to ColorLine     AColor = RGB(0, 0, 0)    For k = 0 To LineNumber        ColorLine(k) = AColor        AColor = AColor + RGB(30, 30, 30)    Next k     .....    'Drawing my data with given line color     For k = 0 To LineNumber         Graf.PSet (Data(1).X, Data(1).Y, ColorLine(k)         For m = 2 To DataPointNumber            Graf.Line -(Data(m).X, Data(m).Y), ColorLine(k)        Next m        Next k     ' and reading line color     Private Sub Graf_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)          ReadColor=Graf.Point(X,y)          .....     End Sub

when i run the program ReadColor different from ColorLine given

Why?

Specific Line Only
I've done a search of the forum and found a mix of replies, but not one that seems particularly usefull. I'm wondering if there is a command to read only the specific (last) line of a text file. Btw, its for a highscores table containing exactly 15 entries, I want to read the last line in to compare to the new score. I know it can be done with *.ini file, but not sure this would be the best method for this. Obviously with only 15 files I could simply read in the whole lot each time, but figured I might aswell try to learn something new while I'm trying.

Any intelligent suggestions welcome. Cheers.

Hi,

How would i go about opening a file and reading watever is on say for example line 10, then out that in a text box??

Thanks

Goto Specific Line
I have a rich text box, that the user can load text files in. The problem is I need to be able to jump to a specific line number of the text box. How is this possible?

Go To A Specific Line In A File
I have different files of all sorts, and I wish to go to the end of the first line, insert a carridge return and line feed. Then insert a string variable and save the file to its original name.

I can't just do a string comparision, because the files will always be different. How can I do this?

Basically, I want to find a specific location in any file.
ie. nth line xth column

Thank you.

How Do I Tell This Line To End In A Specific Spot??
The following code creates a random wavy line.

Code:
Private Sub Timer1_Timer()
Me.Cls
segments = 20
X1 = 100
Y1 = 300
X2 = X1 + Int(Rnd * 20) + 1
Y2 = Y1 + Int(Rnd * 10) - 5
linelength = 300
For t = 1 To linelength / segments
Form1.Line (X1, Y1)-(X2, Y2)
X1 = X2
Y1 = Y2
X2 = X2 + linelength / segments
Y2 = Y2 + Int(Rnd * 10) - 5
Next t
End Sub
as you can see in the code, the line has a fixed start point.
The problem is, it's end point is not fixed. it jumps around like a string being blown in a breeze.

I'm going to use code similar to this to make a 'BumpyLine'
function that I can use to draw realistic coastlines for
random continents. so being able to set a fixed end point is important.

Any help would really be appreciated.

Anyone know how to read a specified line number from a file?

Hi,
In my current project I need to load ever first and every fifth text line (from a txt file for example) to 2 textboxes

However the current code I use only allows me to but all the 10 lines to 10 texboxes and use it after that.
So as far as I know this code is only usable to load either every line to a seperate textbox, or to get the first line from a text file

My current code is:

Private Sub File1_Click()
Open File1.Path + "" + File1 For Input As #1
Line Input #1, a1
Line Input #1, b1
Line Input #1, c1
Line Input #1, d1
Line Input #1, e1

Text1.Text = a1
Text2.Text = b1
Text3.Text = c1
Text4.Text = d1
Text5.Text = e1
End Sub

Hope you can help

Maartuh03

Inputing A Specific Line From A Txt
Ok i want to take a line from a txt file based on a word. For instance if the fifth line has the word "dog" in it it would take the fifth line and make it a variable. By that way is there anyway you can tell it to goto a specific line in general or even find out what line you are on. Thanks in advance.

Hi i have a text file and i would like to read a specific lines in that file. any one with ideas on how i can do that?

Thanks

How To Get Data From A Specific Line?
I want to get data from a file? how to put data in line 2 to a textbox, data in line 3 to a textbox and continue..........

i using code below but come an error "type mismatch" and ReDim Preserve MyArray(i) was highlighted.

Dim temp As String, MyArray As Variant
Open "filename.txt" For Input As #1
While Not EOF(1)
ReDim Preserve MyArray(i)
Line Input #1, MyArray(i)
i = i + 1
Wend
Close

Hello,

I'm looking at writing a password generator that uses real words. In order to do this I've downloaded a relatively small dictionary text file, about 80K words (600kb), with a word-per-line.

Now, my problem is what is the best way to pick a word out of this file randomly, preferably with FSO?

Currently I count the number of lines in the file and use a random number generator to pick a number within the lines-of-file range. This is where I run into problems/issues. I can read each line into an array, and access the random element as required, but is this the best/most efficient way for such a large number of lines?

Thanks.

Cut Selected Line Only(specific)
--------------------------------------------------------------------------------

I cant seem to find how to simply select a certain number of lines, in a text.

On Error Resume Next

'select and cut lines 1 thru x. ??? I already have the line counter x.

'paste elsewhere
'save file
'close file

Approach To Delete A Specific Line From A .txt
I want to delete a specific line (e.g the fifth) from a file. A good (malloc's) solution was to read the first 4 lines and write them to a new file. After that read the 5th line and do nothing with it. Then read the rest of the file and append it to the new file. Kill the old file, rename the new file and that's it.The following was my personal approach to this. The problem is that I got a error when I try to open the second file (error.caption= "File already open").Can anyone help me about it?

currentListSelection = (LstFavorites.ListIndex) 'It takes the number of the current record
Open "FavoritesFile.txt" For Input As #oldFavorites
Open "tempFavorites.txt" For Append As #newFavorites '<--HERE IS THE ERROR
While Not EOF(oldFavorites)
counter = counter + 1
If counter = (currentListSelection + 1) Then '+1 in order for the initial 0 to become 1
Line Input #oldFavorites, TempRecord 'Goes next line to the old file
MsgBox "I do not write a record"
Else
MsgBox "I write a record"
Line Input #oldFavorites, TempRecord 'Goes one line next to the old file
Write #newFavorites, TempRecord 'Writes the record to the new file
End If
Wend
Close #newFavorites
Close #oldFavorites
Kill "FavoritesFile.txt"
Name tempFavorites.txt As FavoritesFile.txt

Specific Line In Text File
Hi. I once figured out how to get a specific line from a text file, but i have lost that code and i now need it, so i wondered if anyone had anything like it?
What it does is, say lineNum=3, it goes through a file until it gets to the line number 3 in the .txt file.
Really need help.
Thanks

How To Read A Specific Line From Txt File?
I wan't to read lats say, line 5 how can I do it?

BTW:
How can I know the end (number) of array?
Or how can I check if array1(3) is ok? (If it's exist)