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




Line Input, Split


hi,

i have a file that input one line at a time, and then i have to extract the third column of data and the people who made the file filled in between columns with spaces (making it 8,000,000 characters long) problem is, for the life of me, i can't get it to extract the third column of numbers

heres a sample of what the file looks like:

175 00:00:24 7 129 5 1 2 2
175 00:00:24 7 127 6 1 2 2
175 00:00:24 11 160 8 1 1 1
175 00:00:24 21 123 2 1 1 1



UPDATE: hold on, the text won't copy right, it keeps removing all the extra spaces




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Line Input #1, Line...how 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 line...how 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
shathoma@nmsu.edu

Input Function (start Reading Input From Inside A Line)
How can I start reading input from the middle of a line?

strText2 = Input(LOF(2), 2)

This puts the entire contents of the file into the string strText2. Is there a way to put upper and lower bounds on the input function so itI can start reading input say at the 10th character to the end of the file?

something maybe like

strText2 = Input(10 to LOF(2), 2) ?

Ive searched around for quite awhile for the answer, and it seems odd that VB would not be able to do this (even though if it cant, im sure theres a good reason for it)

Thanks for any help

Split The Contents Of An Input Box...
I want to split the contents of an input box into seperate variables. For example the input = 1,1,L,2

So i'd have 4 variables, var1 = 1, var2 = 1, var3 = L & var4 = 2

Thanks

.Input ( Read Contentsof Text File - Line By Line )
I'm trying to import Data from a text file, which includes the following,

Vessel Name
000115600
000025600
000000000
000089000
000019000
000000000
6670.43

The above file is updated every five minutes and I wish to retreive this data in
order to perform calc's and then display a completion time for a process on the
User Form.

code:-----------------------------------------------------------------------------
---
Open "YourFile.txt" For Input As #1
While Not EOF(1)
Input #1, YourVariable
List1.Additem YourVariable
Wend
Close #1
--------------------------------------------------------------------------------

Instead of adding to a list as in the above example, I want to process it Line by
Line ( How do I achieve this using .Input ).

Help

Line Input #n,,<string> Stops When [null] Is In The Line
VB6. Using line input #n,,<string. to read a file. It is a txt file and the records are variable length and may contain CTRL characters. When I read a record that has a [null] in it, it takes that as a CRLF and terminates the read. I therefore get a short record and the next record read is the continuation of the first one. My reading tells me that CRLF is the terminator of a record not [null]. A stumper for me. And yes, I am sure there is no CRLF AFTER the null. I read the record character at a time and it is a null all by its lonesome.
Thanks
matt.

Question is: How can I read this record FULLY at one time. I then have to go through and change the null to a space, so it has to be in the record, otherwise everything would shift.

Barcode Split Input Into Three Access Cells
Using Wasp barcode wedge between keyboard and computer. Reading code 128 into cell.

Data is in NNNNDDAAAA formatt where
NNNN=4 charactor Customer ID
DD=2 char month
AAAA=4 char payment amount

I want to split incoming barcode data into these three fields automatically. Any help is appcriciated.

Line Input Question && Line Parse ?
'I would like to change and edit
line 237 of txt file which is "Studentsnameisjohn1234567890"
'465 lines in total

Dim line1 as string
Open C: ext.text For Input As #1

Do Until EOF(1)
Line Input #1, line1

If LCase(Left$(line1, 18)) = "studentsnameisjohn" Then
Text1.Text = Mid(line1, 15, 4) ' Text 1 now displays john

End If
Loop
Close #1

If I decide to edit and parse line1 outside the loop, how do I put line1 back in to #1 after editing ?

For example entering the name "mark" in to text2.text to replace john
mid(line1, 15, 4) = text2.text 'I enter mark in textbox 2

I then click on a command button I call "Apply" to change the name which is where I am stuck as this does not happen ?

End product should look like this for line 237 of txt file "Studentsnameismark1234567890"

I would like to make the name change and then save the text file.

Any help appreciated

Really new at this...

Thx

Append Line To String With Line Input
How do you append a line to a string that I am inputing text into.


Code:
Open "T:crap_email" & strfile For Input As ff 'get a handle on file
length = LOF(ff)

While Not EOF(ff)
Line Input #ff, strfiledata 'input file into a string

Wend

I know about reading the text file all at once with LOF but I am troubleshooting something, and I need to read it line by line.

Faster? Line Input Or Input?
Well, I have a simple question that I tried to solve for myself by simple means... the only problem is, I'm not getting the answer I want...

Is it faster to do Line Input on a .txt file or just Input?

I wanted to test this to see which was the best choice (not for any real reason, just for kicks). Mainly, I wanted to see which handled bigger .txt files better and which was better at smaller ones.

To test this, I set up a simple test:

Have two (2) timers that will bounce back and forth (interval = 10) until the Input or Line Input is done. This way, I can calculate the time taken to input the text from the .txt file. Well... the only problem I came across was... even with an interval of 10, the time came out to 0!

Now, I know what you're thinking: "Maybe you did it wrong?"... I just used a simple intCounter to calculate the time, adding 1 each time the timers were activated. I even checked to make sure the timers were firing right by using a simple "IF...THEN" statement to check if intCounter > 0 when they were allowed to continue even after the text was placed. They fired correctly and the number rose...

So, my problem is:
1. Which one is faster? Has it been proven?
-OR-
2. Is my code messed up?


Code:
Option Explicit
Private intFreefile As Integer
Private strText As String
Private intCount As Integer

Private Sub cmdTest_Click()
'Clear the text
Text1.Text = ""
strText = ""

'Start the counter!
Counter1.Enabled = True

'Input the file by line
Open "C:Documents and SettingsUserDesktop est1.txt" For Input As #intFreefile
Do Until EOF(intFreefile)
Line Input #intFreefile, strText
Text1.Text = Text1.Text & strText
Loop
Close #intFreefile

'Stop the counters after lines have been input till EOF
Counter1.Enabled = False
Counter2.Enabled = False

'Display counter
lblCounted.Caption = intCount
End Sub


Private Sub cmdNormal_Click()
'Clear the text
Text1.Text = ""
strText = ""

'Start the counter!
Counter1.Enabled = True

'Input the file as a whole
Open "C:Documents and SettingsUserDesktop est1.txt" For Input As #intFreefile
Input #intFreefile, strText
Text1.Text = strText
Close #intFreefile

'Stop the counters after the whole document has been input
Counter1.Enabled = False
Counter2.Enabled = False

'Display counter
lblCounted.Caption = intCount
End Sub

Private Sub Counter1_Timer()
'Up the counter by 1
intCount = intCount + 1

'Start 2
Counter2.Enabled = True
Counter1.Enabled = False
End Sub

Private Sub Counter2_Timer()
'Up the counter by 1
intCount = intCount + 1

'Start 1
Counter1.Enabled = True
Counter2.Enabled = False
End Sub

Private Sub Form_Load()
intFreefile = FreeFile
End Sub

Now... I don't know what's wrong with it, but if someone's willing to test it out... I'd appreciate it!

But it all comes down to: Line Input or Input (dependant on file size or is one just better than the other)?


=EDIT=
Oh, and when you input the file (both ways), the vertical bar goes unusable (like it's loading the file). So it should count SOMETHING, right? Even an interval of 1 didn't help...

Getting Data From Line Input #1 To Input #1
Hello Any one
I am Trying To get data From Line Input# to Input#
using the same logic
but i am getting error Input Past End and sometime Subcript out of range
Pl help so that i retain the same logic using Input #1
I've put the codes so that it is easy to compare.

Code:
Private Sub Command1_Click()
Dim file1%, tmp$, fp&, Recs%
file1 = FreeFile
Open "h:Trial.Dat" For Input As #file1
Do While Not EOF(1)
Line Input #file1, tmp

fp = Seek(file1)
Do
Line Input #file1, tmp
Recs = Val(tmp)
Loop Until Recs > 0
Seek #file1, fp


For i = 1 To Recs
Line Input #file1, tmp
MsgBox tmp
Next i
Line Input #file1, tmp
Line Input #file1, tmp
Loop
Close #file1
End Sub


Private Sub Command1_Click()
Dim file1%, tmp$, fp&, Recs%
file1 = FreeFile
Open "h:Trial.Dat" For Input As #file1
Do until eof(1)
i% = i% +1
If i% > Ubound(a$) Then Redim Preserve a$(1 to i%)
If i% > Ubound(b$) Then Redim Preserve b$(1 to i%)
If i% > Ubound(c$) Then Redim Preserve c$(1 to i%)
If i% > Ubound(p$) Then Redim Preserve p$(1 to i%)
If i% > Ubound(q$) Then Redim Preserve q$(1 to i%)
Input #1, a$(i%)

fp = Seek(file1)
Do
Input #1, tmp -------> 'Getting Error Input Past End
Recs = Val(tmp)
Loop Until Recs > 0
Seek #file1, fp

For i = 1 To Recs
Input #1, b$(i%), c$(i%)
MsgBox b$(i%) + c$(i%)
Next i

Input #1, p$(i%), q$(i%)
Loop
Close #1
End Sub



Thanks

Sam F.

Split A Line?
I've got a file with a field that contains comma delimited data. This data field can be quite long, such as
"1,2A,3,4,4A,6,8,10,10A,10B,10C,11,15,16A,18,21,21A,21B,21C" and so on.

I have a second file that this data goes into, except.... the data is going into a MS Access table, and the field, a memo field, is going to only be able to display 24 characters in a report column. So --- what I want to be able to do, if while taking the data from the first table into the second table, using code, check at the 24th character of data, for a comma or for a data split and "chop" the line to as close to 24 characters as possible, tack on a Carrirage return / line feed and then grab the next piece of data and do the same thing, until that line of data is parsed and placed into the table.

Is something like this possible, and how would I go about doing something like that?

Thanks to those who respond..... I think this forum is great!

Split A Line
Hi i have a question. I want to get a line in 2 parts.

It is different everytime Example
C:windows ext.txt

i want it in c:windows and text.txt
so the code gets a variable filename and needs to split it. I tried like

strFName = Right(FileName, "")
strDName = Left(Filename, Len(Filename) - strFName)

But it doesn't work.

Who To Split A Text When Is A New Line
hi,
i want split a text when a have a new line example:
i have this text in a textbox

hello
teste

i want know the name of the character responsable for the new line/paragraf


thanks for your help
bruno

Split Line Up Into Variables
Hi. I have a line of text:

MAN FRI 05:55 PM

Would it be possible to split that up into variables?

i.e "MAN" is the departure point, I would want it to be stored in a variable name DEPARTURE. It occupies the first 3 tabs.

FRI occupies tabs 5-8 and would be stored as DEPDAY.

05:55 PM would be stored as text, in DEPTIME, and it occupies tabs 10-17.

Possible? I know there is kind of a way, something to do with Len? but I am not sure?

Rgds
PP

Split Tooltip In Two Line...
I use the line above to split text in two lines in toooltip, but instead two line have word 2 little sqaure edn second word..
See image

my code:
Me.Image1.ToolTipText = "CAMPANIA" & vbCrLf & "NAPOLI"

Split Txt File With End Of Line
How do i split up a txt file at every linefeed (char13/char10) so every string comes at the right line? (Now everything comes in one long string, but i know there are linefeeds in the file..)

Thank you for good help!

Loading List && Line Split Help
I'm trying to load a text file into my program that looks like this:


Code:
"Hemostat"
"AV Clamp"
"1"
"CV"
"Speculum"
"Van Buren Sounds"
"2"
"GYN"
"Needle Driver"
"Max Rex"
"3"
"Neuro"
I want the program to just pull the first two instruments and place them in a textbox with this format (instrument1:instrument2), so for example, the textbox would look like this:

Code:
Hemostat:AV Clamp
Speculum:Van Buren Sounds
Needle Driver:Max Rex
I can't seem to get past loading the text file before I'm stumped. I know that I need to assign the first line read to a variable and do the same with the second line read and discard the other two lines read and repeat.....I just don't know how to code that. Is there a way I can load a whole bunch of values into "b" and then just recall it by doing b(0), b(1), b(2), b(3), etc?


Code:
Private Sub mnuConvertInstruments_Click()
Dim a As String
Dim b As String
Dim i As Integer

On Error Resume Next
With CommonDialog1
.filename = ""

.InitDir = App.Path
.Filter = "Text Files (*.*)|*.*"
.ShowOpen
If Len(.filename) Then
Set fs2 = New FileSystemObject
Set ts2 = fs2.OpenTextFile(.filename, ForReading, False)

Do While Not ts2.AtEndOfStream


b() = ts2.ReadLine
b = Replace(b, """", "")
text1.text = b

Loop

ts2.Close
Set ts2 = Nothing
End If
End With
End Sub

Parse Command Line With Split
I am parsing the text contained in the command $
IN VB, in Project ...Properties..Make tab..I typed "1 2" for the Command Line Arguments.

Then I run the code below: I get the MsgBox 1 2 (for the sCmdLn) but then VB highlights this line: "varArray = Split (sCmdLn," ",-1,vbTextCompare). " and I get the error : Run Time error 13: Type Mismatch.
What am I doing wrong?

Thanks


Private Sub Form_Load()

Dim sCmdLn$, sFrom$, varParm1, varParm2
Dim varArray() As Variant

sCmdLn = Command()
If sCmdLn <> "" Then
MsgBox sCmdLn
varArray = Split(sCmdLn, " ", -1, vbTextCompare)
sFrom = varArray(0)
varParm1 = varArray(1)
varParm2 = varArray(2)
MsgBox varParm1
MsgBox varParm2
Else
MsgBox "There are no arguments"
End If

Split A Line From A Txt File With Tab Into An Array
How would I split a line that has a tab in the line?
For example I have an ascii file that contains multiple lines.
Each line looks something like this:
'value' 'three tabs' /*'definition of value'*/
What would I use to split the line if all I want is the value.

Code:
strPipingSchemaArr = Split(strPipingSchema, " ") 'what would I put instead of the space
txtPiping.Text = strPipingSchemaArr(0)

Any help would be greatly appreciated.

How To Split A Text File After Any Particular Line I Specify.
How can I split a text file programtically after the line number I specify.

Please Help.

Line Input Not Reading A The Whole Line
I am using Line Input to read lines out of a file.  On loop 1, the code is reading the first line and printing to another file correctly.  On loop two, Line Input is not reading the second line.  It doesn't print anything (visible) into the output file.  This does not happens on every line.  For instance, it takes 7 loops to copy 5 lines to the second file.  I do not have access the code that writes the input file.  I am thinking there is some kind of code at the end of some of these lines that interrupts Line Input from reading the to the end of line.  I need to make sure I am accouting for the number of lines that are being read.

Attached is the first 7 lines of the input file

-Jeff C:DocumentsandSettingsCulliJP1DesktopARAV-CBKM203AR2stageAero2stageAeroInput.dat

Joining A String Which Is Split By Carriage Return Line Feed
Hello,

I'm stuck in a situation now..I hope someone out there can help get me out of it...here's the situation:

I now have a string as follows:

abcstring =

ABCDEFG
HIJKLMNO
PQRSTUV
WXYZ


how am I able to join all the strings to form a string

ABCDEFGHIJKLMNOPQRSTUVWXYZ

i.e. delete off the carriage return line feed


Thanks in advance!

Joe

Line Input
Hi everyone!

i have a little problem with my textfile - which look like this:

Number1.1 Number2.1 Number3.1 Number4.1
Number1.2 Number2.2 Number3.2 Number4.2
Number1.3 Number2.3 Number3.3 Number4.3
Number1.4 Number2.4 Number3.4 Number4.4
Number1.5 Number2.5 Number3.5 Number4.5

Number1.6 Number2.6 Number3.6 Number4.6
Number1.7 Number2.7 Number3.7 Number4.7
Number1.8 Number2.8 Number3.8 Number4.8
Number1.9 Number2.9 Number3.9 Number4.9
etc...
(the free space is a TAB and sometimes there is a blank line)



What i need to do is that i want to make a textfile which look like this:

Number4.1 Number4.6
Number4.2 Number4.7
Number4.3 Number4.8
Number4.4 Number4.9
and so on....


Ok hier i have the code to do it with the first row:


Code:
Option Explicit

Private Sub Command1_Click()
Dim Row1 As String
Dim Ary() As String
Dim Zeile As Byte

Zeile = 0

Open "C: est.txt" For Input As #1
Hier:
Do While Not EOF(1)
Line Input #1, Row1

If Row1 = "" Then
Zeile = 0
GoTo Hier
End If
If Zeile = 1 Then GoTo Hier

Ary = Split(Row1, vbTab)
L = L & vbTab & Ary(3)
Zeile = 1
Loop


Close #1
End Sub

it works fine - i just print the "L" into a textfile....

But how can i do it with all the other rows at the same time?????
i attatched the file if you want to try it.
Please help me - i really should finish this....

Thanks

Line Input
Ive got a text file as follows:

27,69,4.6960e+02
29,69,7.4857e+01
30,69,1.8109e+02
86,69,1.0869e+02
87,69,7.4534e+01
88,69,7.4817e+02
171,69,5.6081e+01
23,68,6.5628e+02
24,68,4.6494e+02
27,68,4.6484e+02
32,68,5.0456e+01
33,68,2.6307e+03
20,67,8.2752e+02
21,67,2.8618e+02
23,67,5.3088e+02
24,67,6.5093e+02

which appears like this when opened in Wordpad or when brought into a RTF box in VB. In notepad it is very messy. However when I try to do a line input on it (in the RTF box) the whole file is inputed. Any ideas on how to get VB to recognise the lines?

p.s. inputting by no. of characters won't work coz some lines have more characters than others (e.g. longer no.s, negative symbols etc..).

Line Input
I am interested in being able to use Line Input to bring any arbitrary line from a text file.

for instance: How do I use Line Input to input say line 5 of text in a file?

-----------------------------------
line1 data1
line2 data2
line3 data3
line4 data4
line5 data5
______________________

Without using mid() left() right() how do i go about just picking line 5 and inputting it to a value no matter what other lines contain?

Line Input
I'm having a problem reading in two integers from a text file. The map looks like this:

75, 80
11110000111001
11000011000011
12222200001100
12222000002200

What I'm trying to do is read in the 75 and the 80 integers and assign them to different variables(toY and toX). This is the code I have so far, I know its wrong, can someone please tell me whats wrong? Thanks.


Code:
Open App.Path + "map.txt" For Input As 1
For toY = 1 To 1
Input #1, strY
toY = strY
Next

For toX = 1 To 1
Input #1, strX
toX = strX
Next

Close

Line Input # 1
When I use Line Input, it doesn't seem to read the entire line. It stops at each comma (,). How do I get VB to read the entire line regardless of what characters (text characters) is on the line.

Thanks.

Input Line
hey, i've got a file (that is formated in columns) and that is delimited by spaces. I would prefer this to be delimited by tabs, but the people who made it are idiots...so.

anyways, i need to get all the data from the fourth column, and i figured the best way to do this would be to input a line and then use the split function and get the 4rd column, (even though split will return all those spaces as extra columns)

i thought line input #1, StrVar would do it, but it seems to be getting the entire file possibly because i waited about a 2 minutes and the file is actually 8MB, but 2 minutes is an awful long time to wait to input one line. the only thing i could think of was that the end of the lines weren't being recognized so i looked at the file and they're ended by a Chr(10) (linefeed), so does input line not recognize that? or is there a better way of doing this?

thanx

Line Input
What is the best way to open any file for input (not just text) and read the info byte by byte (character by character).

does lobyte, hibyte, loword, hiword apply here?

I'm examining the header signature of a file and some other things. I need to be able to navigate these files.

Any help would be greatly appreciated.

Line Input
Line Input gets a line in a text file. Is there something like that against string buffer. Example, Kedaman showed me how to get an entire text file into a string. I want to know if there is a way to go through each carriage return or do I have to program a function that is similar to Line Input.

Line Input - Help!!!
I want to do a Line Input after I found a certain word. So, if I found the word through a text file, I want to do the Line Input in the next line.

Any suggestion???

Line Input
Hello!

I use Hoffman algorithm to compress string. It adds vbCr at the beginning of compressed string's header. Then I want to load that string from file. In notepad I see all text in one line so I used Line Input # statement. But I realised that I was wrong, because Line Input accepts vbCr as enter (new line), so it ends here even if it has read just 2 charachters.

How can I read whole line without using Line Input # statement which doesn't work?

Line Input# With Just Chr(10)
I have a need to be able to use the Line input# function to read one line of a text file into a variable however some lines only end with vblf (chr(10)) , not the usual vbcr & vblf (chr(13) chr(10)). Any ideas on how to make this work without re-writing the whole Line Input# function? Any help would be greatly appreciated.

Thanks,
Mike

Line Input
If I want to retrieve some information from a hex file and I know for a fact that the info that I require is held in lets say line 566 then is there a quick direct way of going straight to that line and skipping the first 565 lines. At the moment I am using a counter and just using Line Input until it reaches the required Line number. Untidy I think, thats why Im asking.

Line Input
He guys,
Is there away to jump directly to a certain linenumber for example line 26, instead of looping like this?

dim i as integer
dim tmp as string

i = 0
Open "c: est.txt" for input as #1
Do while not eof(1)
If i=26 Then Msgbox "Line 26"
Line Input #1, tmp
i=i+1
Loop
close#1


Thanks a lot allready

Input Line Help
Print #File, "echo %computername% &gt;&gt; \" & sComputerName & "c$Log.txt"

how come this only adds the line:
echo %computername% &gt;&gt; \computername

with out the C$log.txt
?

Line Input Until End Of File?
How can I loop a Line Input "File I/O" until the end of the file and then just stop. Thanks in advance for any help.

Line Input Query
Hi people..

I'm using Line Input # to read from a text file. As I understand it, Line Input # should recognise carriage return / line feed as the end of the line yeh?

Only in my case.. it's appears to be interpreting comma's as EOL chracters too.. (which is a bit annoying as the text file contains filenames.. which often include comma's - I want it to pick up the whole line.. not split the filenames which have comma's in them!)

Any ideas? Or am I just being stupid?

Any help greatly appreciated.. you'll go to heaven ya know (not just yet though I hope!)

Darren

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)

Multi Line Input
is there anyway to get multi line input from a user other than having them put it on a worksheet?

Skip A Line During Input
Hi all!


Code:

Do Until EOF(1)
Line Input #1, strLine
strFields = Split(strLine, " ; ")
If Val(Left$(strFields(3), 1)) > 1 Then
' Just skip this line in the file and move on to the next
Else
' Do stuff
End If
Loop
Does anyone know what line I use where I have the comment
Quote:




' Just skip this line in the file and move on to the next




I am importing the data from the file into an Access Database and I don't want the data to be imported if certain conditions apply. Thanks for any input.

Tabs In Line Input
I am using Line Input to go through text files in order to retrieve data. When I get the line, all of the tab locations in the file aren't spaces anymore. They are vertical bars.

I need to keep them as spaces or find some other way of getting around to the data.
Thanks
Gilmesh


Here's two examples of the code i'm using if it helps.

'Loop to lines with desired values and retrieve
Do Until Left$(strInput, 9) = "Paid Outs"
Input #FileTrans, strInput
Loop

PaidOut = Extract(strInput, 17, 24)

and

Private Function Extract(strInString As String, intStartPos As Integer, intLastPos As Integer) As Long
'MID$ function with data formating
Dim strOutString As String
Dim strTemp As String
Dim lngResult As Long
Dim index As Integer

strOutString = ""

'get requested string
strTemp = Mid$(strInString, intStartPos, intLastPos)

'Check for larger numbers
Do While Mid$(strInString, intLastPos + 1, intLastPos + 1) <> ""
strTemp = strTemp + Mid$(strInString, intLastPos + 1, intLastPos + 1)
Loop

'Remove commas and format
For index = 1 To Len(strTemp)
If Mid$(strTemp, index, 1) <> "," Then
strOutString = strOutString & Mid$(strTemp, index, 1)
End If
Next index
MsgBox strOutString
strOutString = Trim(strOutString)
lngResult = CLng(strOutString)

Extract = lngResult

End Function



Here's part of the txt file

Change Returned For Checks0.000.00
Paid Outs0.000

HELP!! Line Input Method...
i'm dying here, my major project is due in 18 hrs, the culmination of 6 months work....

i'm looking for a fast way to join together x number of files. what i do currently is

Open bigfile For Output As #43

For i = 0 To numberofsubfiles

If fso.FileExists(subfile & i) Then
Open subfile & i For Input As #42

While Not EOF(42)
Line Input #42, tempstr
Print #43, tempstr
Wend

Close #42
Print #43, "[break here]"
End If

Next i

Close #43

what this should do is get each of the subfiles and put them all in a big file, each file being separated by a line "[break here]

the thing is that today the line iput function has decided it's not goign to read line 3 of subfile1, and it'll read the second half of line 4 twice...the rest of it is fine...but the header needs to be right or everything else dies...

1. can anyone suggest why this is happening
2. can anyone suggest a better way to link these files together...

thanx everyone.....and type your replies fast



The fact that nobody understands you doesn't mean you're an artist.

How Do I Input Only 1 Line From A File
I need to know thanks. The file is from a word processor.

Input Command Line
When I drag and drop a single file to the compiled executable file with the following command in the Form_Load it works as well.
If Command <> "" Then Editor.LoadDocument Command
But if I drag and drop more than 1 file it won't work.
So, how to get the first file name and disregard the rest of them?

Skip A Line If No Input?
okay, i have asked this before, and i didnt understand what people were getting at...and im going to try one more time, lol. How can i make it so that if there is a certain input in a textbox, then it will no show up in the display? i dont want it to leave a blank space, i just want the one that would be under it to take its spot. How would i do this? here is the ENTIRE code for my program.


Code:
Private Sub cmdClear_Click()
txtMainChar = "Main Character"
txtChar1 = "Character 1"
txtChar2 = "Character 2"
txtChar3 = "Character 3"
txtChar4 = "Character 4"
txtChar5 = "Character 5"
txtChar6 = "Character 6"
txtChar7 = "Character 7"
txtChar8 = "Character 8"
txtChar9 = "Character 9"
txtChar10 = "Character 10"

optNovel = False
optShort = False
optPoem = False
optScreen = False

optFiction = False
optNonFiction = False

optMystery = False
optHistoricalFiction = False
optFantasy = False
optHorror = False
optSuspense = False
optDrama = False
optSciFi = False

optHistory = False
optScience = False

txtTitle = ""
txtSetting1 = ""
txtSetting2 = ""
txtSetting3 = ""
txtSetting4 = ""
txtSetting5 = ""
txtSetting6 = ""

txtSynopsis = ""
lblDisplay = ""
End Sub
Private Sub cmdExecute_Click()
lblDisplay = "Title:" & txtTitle
lblDisplay = lblDisplay & vbCrLf & "Main Character:" & txtMainChar
lblDisplay = lblDisplay & vbCrLf & "Side Characters:"
lblDisplay = lblDisplay & vbCrLf & txtChar1
lblDisplay = lblDisplay & vbCrLf & txtChar2
lblDisplay = lblDisplay & vbCrLf & txtChar3
lblDisplay = lblDisplay & vbCrLf & txtChar4
lblDisplay = lblDisplay & vbCrLf & txtChar5
lblDisplay = lblDisplay & vbCrLf & txtChar6
lblDisplay = lblDisplay & vbCrLf & txtChar7
lblDisplay = lblDisplay & vbCrLf & txtChar8
lblDisplay = lblDisplay & vbCrLf & txtChar9
lblDisplay = lblDisplay & vbCrLf & txtChar10
lblDisplay = lblDisplay & vbCrLf & "Setting:"
lblDisplay = lblDisplay & vbCrLf & txtSetting1
lblDisplay = lblDisplay & vbCrLf & txtSetting2
lblDisplay = lblDisplay & vbCrLf & txtSetting3
lblDisplay = lblDisplay & vbCrLf & txtSetting4
lblDisplay = lblDisplay & vbCrLf & txtSetting5
lblDisplay = lblDisplay & vbCrLf & txtSetting6
lblDisplay = lblDisplay & vbCrLf & "Synopsis:" & txtSynopsis

'Novel Fiction
If optNovel = True And optFiction = True And optMystery = True Then
lblDisplay = lblDisplay & vbCrLf & "Fiction Mystery Novel"
End If
If optNovel = True And optFiction = True And optHistoricalFiction = True Then
lblDisplay = lblDisplay & vbCrLf & "Historical Fiction Novel"
End If
If optNovel = True And optFiction = True And optFantasy = True Then
lblDisplay = lblDisplay & vbCrLf & "Fantasy Novel"
End If
If optNovel = True And optFiction = True And optHorror = True Then
lblDisplay = lblDisplay & vbCrLf & "Horror Fiction Novel"
End If
If optNovel = True And optFiction = True And optSuspense = True Then
lblDisplay = lblDisplay & vbCrLf & "Suspense Fiction Novel"
End If
If optNovel = True And optFiction = True And optSciFi = True Then
lblDisplay = lblDisplay & vbCrLf & "Fiction Sci-Fi Novel"
End If
If optNovel = True And optFiction = True And optDrama = True Then
lblDisplay = lblDisplay & vbCrLf & "Dramatic Fiction Novel"
End If
'Poem Fiction
If optPoem = True And optFiction = True And optMystery = True Then
lblDisplay = lblDisplay & vbCrLf & "Fictional Mystery Poem"
End If
If optPoem = True And optFiction = True And optHistoricalFiction = True Then
lblDisplay = lblDisplay & vbCrLf & "Historical Fiction Poem"
End If
If optPoem = True And optFiction = True And optFantasy = True Then
lblDisplay = lblDisplay & vbCrLf & "Fantasy Poem"
End If
If optPoem = True And optFiction = True And optHorror = True Then
lblDisplay = lblDisplay & vbCrLf & "Horror Fiction Poem"
End If
If optPoem = True And optFiction = True And optSuspense = True Then
lblDisplay = lblDisplay & vbCrLf & "Suspense Fiction Poem"
End If
If optPoem = True And optFiction = True And optSciFi = True Then
lblDisplay = lblDisplay & vbCrLf & "Science Fiction Poem"
End If
If optPoem = True And optFiction = True And optDrama = True Then
lblDisplay = lblDisplay & vbCrLf & "Dramatic Fiction Poem"
'Short Story Fiction
If optShort = True And optFiction = True And optMystery = True Then
lblDisplay = lblDisplay & vbCrLf & "Short Mystery Fiction Story"
End If
If optShort = True And optFiction = True And optHistoricalFiction = True Then
lblDisplay = lblDisplay & vbCrLf & "Short Histoical Fiction Story"
End If
If optShort = True And optFiction = True And optFantasy = True Then
lblDisplay = lblDisplay & vbCrLf & "Fantasy Short Story"
End If
If optShort = True And optFiction = True And optHorror = True Then
End If
lblDisplay = lblDisplay & vbCrLf & "Fictional Horror Short Story"
End If
If optShort = True And optFiction = True And optSuspense = True Then
lblDisplay = lblDisplay & vbCrLf & "Suspensful Fiction Short Story"
End If
If optShort = True And optFiction = True And optSciFi = True Then
lblDisplay = lblDisplay & vbCrLf & "Science Fiction Short Story"
End If
If optShort = True And optFiction = True And optDrama = True Then
lblDisplay = lblDisplay & vbCrLf & "Dramatic Fictional Short Story"
End If
'Screen Play Fiction
If optScreen = True And optFiction = True And optMystery = True Then
lblDisplay = lblDisplay & vbCrLf & "Fictional Mystery Screen Play"
End If
If optScreen = True And optFiction = True And optHistoricalFiction = True Then
lblDisplay = lblDisplay & vbCrLf & "Historical Fiction Screen Play"
End If
If optScreen = True And optFiction = True And optFantasy = True Then
lblDisplay = lblDisplay & vbCrLf & "Fantasy Screen Play"
End If
If optScreen = True And optFiction = True And optHorror = True Then
lblDisplay = lblDisplay & vbCrLf & "Horror Fictional Screen Play"
End If
If optScreen = True And optFiction = True And optSuspense = True Then
lblDisplay = lblDisplay & vbCrLf & "Suspensful Fictional Screen Play"
End If
If optScreen = True And optFiction = True And optSciFi = True Then
lblDisplay = lblDisplay & vbCrLf & "Science Fictional Screen Play"
End If
If optScreen = True And optFiction = True And optDrama = True Then
lblDisplay = lblDisplay & vbCrLf & "Dramatic Fictional Screen Play"
End If
'Novel Non-fiction
If optNovel = True And optNonFiction = True And optHistory = True Then
lblDisplay = lblDisplay & vbCrLf & "Non-Fiction History Novel"
End If
If optNovel = True And optNonFiction = True And optScience = True Then
lblDisplay = lblDisplay & vbCrLf & "Non-Fiction Science Novel"
End If
'Poem Non-Fiction
If optPoem = True And optNonFiction = True And optHistory = True Then
lblDisplay = lblDisplay & vbCrLf & "Non-Fiction History Poem"
End If
If optPoem = True And optNonFiction = True And optScience = True Then
lblDisplay = lblDisplay & vbCrLf & "Non-Fiction Science Poem"
End If
'Short Story Non-Fiction
If optShort = True And optNonFiction = True And optHistory = True Then
lblDisplay = lblDisplay & vbCrLf & "Non-Fiction Historical Short Story"
End If
If optShort = True And optNonFiction = True And optScience = True Then
lblDisplay = lblDisplay & vbCrLf & "Non-Fiction Science Short Story"
End If
'Screen Play Non-Fiction
If optScreen = True And optNonFiction = True And optHistory = True Then
lblDisplay = lblDisplay & vbCrLf & "Non-Fiction Historical Screen Play"
End If
If optScreen = True And optNonFiction = True And optScience = True Then
lblDisplay = lblDisplay & vbCrLf & "Non-Fiction Science Screen Play"
End If
End Sub
Private Sub cmdPrint_Click()
Printer.Print lblDisplay.Caption

Printer.EndDoc
End Sub

Private Sub Exit_Click()
End
End Sub

Private Sub Help_Click()
Form2.Show
End Sub

Private Sub Print_Click()
Printer.Print lblDisplay.Caption

Printer.EndDoc
End Sub

Confusion Over Line Input
Hi,

I have got a friday afternoon teaser. Well it managed to confuse me.

I am using the code below to read a csv file lile by line and it works when I use a test file of about 30 records, however when I use the main file which is about 150000 records it falls over with an overflow error. Why is it when i read in the sample file it reads in line by line but with the main file it tries to read the whole file in to my string variable -making it fall over.

Any suggestions appreciated. I have attached the sample file as reference. I think it only has a CR at the end, could that be a problem

Thanks in advance

Gogi

VB Code:
dim  temp as String        mainFile = FreeFile        Open txtFileName For Input As mainFile            Line Input #mainFile, temp

Line Input Question...
ook am I being dumb? or wait... actually dont answer that!

lol

why cant I do this:

Open files... etc

Line Input #1, txtZoom

it wont let me read into a textbox??

Line Input Question
is there an substitute for the 'line input' command
that will just return individual characters in the file?

ie

Code:
Open "test.txt" For Input As #1
Do While Not EOF(1)
Line Input #1 ,incoming
text1.text = text1.text & incoming
Loop
Close #1

will return an entire line in a file

and i want to know if open can return just the individual
characters or if i have to parse each line manually.

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