473,405 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

getting 1 line out of a multi line file

3
ive looked for this and the basic code for inputs but it doesnt have anything about this

example: say my file looks like this
-------------
yes
no
1
14
-------------

can i get just the 3rd line to get the number 1?
code would help too

thx
Dec 10 '06 #1
2 1330
jimb20
3
also what is the command to stop the program when it becomes unresponsive (like when u have an enless loop)
Dec 10 '06 #2
Killer42
8,435 Expert 8TB
ive looked for this and the basic code for inputs but it doesnt have anything about this
example: say my file looks like this
-------------
yes
no
1
14
-------------
can i get just the 3rd line to get the number 1?
code would help too
I don't think there's any simple way to jump directly to the third line, unless they are fixed-length records (which doesn't appear to be the case). This code should produce the desired end, though. I'm assuming we're dealing with VB6, because (A) you didn't say, and (B) that's what I'm familiar with. :)
Also, the code is a little longer than strictly necessary, as I've tried to make it more generally applicable rather than just hard-coding everything. For instance, you can change which line by varying the value of LinesToSkip.
Expand|Select|Wrap|Line Numbers
  1. Dim FileNum As Long
  2. Dim LinesToSkip As Long
  3. Dim Text As String
  4. LinesToSkip = 2
  5. FileNum = FreeFile ' Get next available file number.
  6. Open "TheFile.txt" For Input Access Read Shared As #FileNum
  7. For I = 1 To (LinesToSkip + 1)
  8.   Line Input #FileNum, Text
  9. Next
  10. Close FileNum
  11. ' You now have the third line in Text.
  12.  

also what is the command to stop the program when it becomes unresponsive (like when u have an enless loop)
Not sure exactly what you mean. If you're in the IDE, then you can just click the stop or pause button, or hit Ctrl-Break to interrupt. I don't think there is anything your program can easily do about the situation.

Except to stop looping, I suppose. :)

If you are executing compiled code and it doesn't provide any way to stop it, then you can use the Windows task manager to kill it.
Dec 10 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Parrot | last post by:
Does anyone else have a problem with the Mozilla browser not expanding a multi-line textbox to its proper size? My textboxes are all small and do not display mu;tiple lines in Mozilla or Netscape...
6
by: cody | last post by:
What are multi file assemblies good for? What are the advantages of using multiple assemblies (A.DLL+B.DLL) vs. a single multi file assembly (A.DLL+A.NETMODULE)?
8
by: Peter A. Schott | last post by:
Per subject - I realize I can copy/paste a line at a time into an interactive session when I'm trying to debug, but was wondering if there is any tool out there that allows me to copy sections of...
3
by: stax | last post by:
Hello, can somebody tell me how to serialize/deserialize a object containing a multi line string using the XmlSerializer class. One of the both windows linefeed chars get dumped somewhere down...
3
by: Jow Blow | last post by:
I am trying to make a word wrap type function for a multi line text box field that will be saved to a text file. The word wrap property looks good in the app but when saved to a text file the line...
23
by: Kaz Kylheku | last post by:
I've been reading the recent cross-posted flamewar, and read Guido's article where he posits that embedding multi-line lambdas in expressions is an unsolvable puzzle. So for the last 15 minutes...
11
by: rossum | last post by:
I want to declare a const multi-line string inside a method, and I am having some problems using Environment.NewLine. I started out with: class foo { public void PrintStuff() { const...
1
by: mknoll217 | last post by:
I am recieving this error from my code: The multi-part identifier "PAR.UniqueID" could not be bound. The multi-part identifier "Salary.UniqueID" could not be bound. The multi-part identifier...
4
by: MartinRinehart | last post by:
Thinking about unclosed multi-line quotes. When you open a multi-line quote (type '"""') what does your editor do? Does it color the remainder of your text as a quote, or does it color the line...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.