Input .csv File To VB, With Selected Line
hi, i am a very beginner of VB, and having so much trouble, i have few question plz give me a help, or give me some example... the case i am doing is to into the database file .csv into VB 1) how do i input my .csv file As file__name 2) if i need to compare the number from my csv file, such as, matching my input to the database file .csv in some Specaific area, do i need to input whole .csv file into vb? or just make a array or something? 3) in my .csv file, there are Date, Number 1, number 2, number 3 if i need to match the Number was inputed by Date, how can i do that below is a example, plz give me a help to write the code, thx. best regards
my Input:
from date: 1/3/2001 to date: 5/5/2001 number input: 1, 5, 51
Data, from csv file
1/1/2001 5, 7, 11 5/1/2001 1, 3, 27 *15/4/2001 3, 25, 44 *25/4/2001 5, 31, 41 *5/5/2001 7, 21, 27 27/5/2001 8, 14, 19
ps. the *sign mean the number i need to compare in this case, which is given from my input
in this case what will be the most easy way to complete the code. plz help me thank you
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Input .CSV Database File Into VB, By Only Input The Selected Area
hi, i am a very beginner of VB, and having so much trouble, i have few question plz give me a help, or give me some example...
the case i am doing is to into the database file .csv into VB
1) how do i input my .csv file As file__name
2) if i need to compare the number from my csv file, such as, matching my input to the database file .csv in some Specaific area, do i need to input whole .csv file into vb? or just make a array or something?
3) in my .csv file, there are Date, Number 1, number 2, number 3
if i need to match the Number was inputed by Date, how can i do that
below is a example, plz give me a help to write the coding, thx.
best regards
my Input:
from date: 1/3/2001
to date: 5/5/2001
number input: 1, 5, 51
Data, from csv file
1/1/2001 5, 7, 11
5/1/2001 1, 3, 27
*15/4/2001 3, 25, 44
*25/4/2001 5, 31, 41
*5/5/2001 7, 21, 27
27/5/2001 8, 14, 19
ps. the *sign mean the number i need to compare in this case, which is given from my input, the data is tread by Date
in this case what will be the most easy way to complete the code. plz help me
thank you
How To Input .CSV Database File Into VB, By Only Input The Selected Area
hi, i am a very beginner of VB, and having so much trouble, i have few question plz give me a help, or give me some example...
the case i am doing is to into the database file .csv into VB
1) how do i input my .csv file As file__name
2) if i need to compare the number from my csv file, such as, matching my input to the database file .csv in some Specaific area, do i need to input whole .csv file into vb? or just make a array or something?
3) in my .csv file, there are Date, Number 1, number 2, number 3
if i need to match the Number was inputed by Date, how can i do that
below is a example, plz give me a help to write the coding, thx.
best regards
my Input:
from date: 1/3/2001
to date: 5/5/2001
number input: 1, 5, 51
Data, from csv file
1/1/2001 5, 7, 11
5/1/2001 1, 3, 27
*15/4/2001 3, 25, 44
*25/4/2001 5, 31, 41
*5/5/2001 7, 21, 27
27/5/2001 8, 14, 19
ps. the *sign mean the number i need to compare in this case, which is given from my input, the data is tread by Date
in this case what will be the most easy way to complete the code. plz help me
thank you
.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 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.
Reading Input File - Saving One Line From The File
I am reading an input file line by line and I need to 'extract' [i.e. save to a string] just one line, where the line begins with 'ClaimHeaders*'.
I am just struggling with how to save just that one line to the string. This is what I have so far.
Sub Main()
Dim myFile
myFile = "c:
eprice1.5clmsys01NOTHMAN.repricer.ini"
Dim fileId As Long
Dim strFile As String
Dim sText As String, i As Integer
Dim arLines() As String, arTemp() As String
Dim myCount
Dim myText
fileId = FreeFile()
Dim x As Integer
Dim aString, extractedString As String
aString = "ClaimHeaders*"
Open myFile For Input As #fileId
Do While Not EOF(1)
Line Input #fileId, myText
If myText Like aString Then
<extract that line to a string...this is where I am stuck>
Debug.Print aString
End If
Debug.Print myText
Loop
Close #fileId
End Sub
The input text file looks like this:
#Repricer Preferences
#Fri May 25 09:24:27 CDT 2007
Logging=Debug
MainSize=1024,740,224,275
ClaimHeaders=0|155,1|195,2|90,3|85,4|60,5|90,6|30,7|60,8|90,9|90,10|90,11|60,12|105,14|60,13|149
UseExternalBrowser=Yes
StopWatch=false
MaximumClaimsReturned=200
Debug=true
Browser=C:\Program Files\Plus!\Microsoft Internet\Iexplore.exe
Line Input And File Problems
Hey all, I am having a slight problem loading data from a file. I am developing an application for some call reporting software where groups can be created and extensions allocated to those groups. The way I have done this is saved the groups file in this format:
*Group name
extensions go here, each one seperated by a line break
###
the ### is used to seperate each group in the file, so when im loading individual groups back in I can tell it to stop loading the extension numbers as soon as it reaches the ### in the file. I have a combo box that populates itself with the names of the groups. It checks to see if the first character is a * and if it is, it loads that line into the box, removing the * first. I have created a button that will view the extensions of that group when the group name is selected in the combo box, so far this is what I have:
VB Code:
Open App.Path & "groups.dat" For Input As #2While Not EOF(2)Line Input #2, groupext$If RTrim(cmbgroup.Text) = RTrim(Mid$(groupext$, 2, 15)) ThenDo While RTrim(groupext$) <> "###"lblextensions.Caption = lblextensions.Caption & groupext$LoopElseMsgBox "group not found"End IfWendClose #2
Currently this crashes my application, im having problems getting my head round the best way of doing this, if anyone can help me I would be very grateful.
Thanks.
Start New Line During File Input
How would a start a new line
Private Sub Load_Click()
Dim sline As String
Open "c:
ew.txt" For Input As #1
Do Until EOF(1)
Line Input #1, sline
Text1.Text = Text1.Text & sline /want to start new line here/
Loop
Close #1
End Sub
Input Hole Line From File
Every time I try to get a line from a text file into a variable the variable picks everything up till it reaches a comma. How do I get a full line without anything delimiters stopping me.
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
Loading A Line Input On A Text File
Why do I get a compile error: Argument not optional - highlighted at EOF? with the following?
Open "C:Program FilesCentralOrder Entryusers.txt" For Input As #1
Do Until EOF
Line Input #1, USER1
Loop
Close #1
Any help is appreciated.
Thanks
Multi Line Input From A Text File
I need a little bit of help parsing a text file. Here's the scoop,
I'm doing a line input on a text file that has the following format:
"Blah1 Blah2 BlahBlahBlah3","Blah4"
"BlahBlahBlah3(Continued)","Blah4(Sameasfirstline)"
"Blah1 Blah2 BlahBlahBlah3","Blah4"
"BlahBlahBlah3(Continued)","Blah4(Sameasfirstline)"
Some lines have the second line, but most don't have it.
I all ready know how to do a LINE INPUT # on the first line, but I can't get a split to work correctly. It doesn't seem to recognize that I want to split on "," (Chr(34) & Chr(44) & Chr(34)) and not on , (Chr(44) due to BlahBlahBlah3 containing commas.
I have some code built all ready, but I could really use some help and a general pointer in the right direction.
Thanks,
Steve
Reading In A Line And Writing Input To A File
i am trying to read in a line and grab certain lines of information. For example, i have a:path.blahfolderpartname, , approved, 1, 1, 1234ABDC, , prerelease
i want just partname and the approved and 1234ABCD info written to a text file
in somewhat this format
partname
approved
1234ABCD
thanks..
Retrieve A Line After Using Open File For Input As??
Hey every one my help is not installed on the pc im using at the mo and i am just trying to remember the syntax for using lineinput with a file opened for input
if someone could post an example or the correct syntax it would be great
thanks everyone
Input Text File Blank Line
i want to read (input #1,a) a text file which contains blank lines (ie CR, LF only).
input #1,a skips to the next line of text.
any other way to do this without opening as binary and readed all file into one string & parsing it.?
Line Input # Reads Entire Text File All At Once?
Hi! I need to read line by line from a plain text file (not data of any kind, originally created on Unix and then copied to C:), do pattern match, and process IF-THEN accordingly. For example, if the text file contains "margin", the word after "margin", e.g., "binding" in the example below, will be copied to a VB string for steps later.
The text file looks like this.
***************************
*- PROGRAM NAME:...
***************************
% margin = binding
My problem is when I read the text file in by Line Input #1, it reads the entire file in all at once (so there is only one LOOP). Here is my code. What went wrong?
Dim TextLine1 As Variant
Open FName For Input As #1 'Open File
Do While Not EOF(1)
Line Input #1, TextLine1
Debug.Print TextLine1
Loop
Close #1
File I/O Line Input - Language Syntax Issue
Hai
Code:
fpath = App.path & " est.txt"
fno = FreeFile()
Open fpath For Input As #fno
Do While Not EOF(fno)
Line Input #fno, line
MsgBox line
Loop
My question is, In the above code we are reading lines from test.txt.
why it is called Input? should it be sound like Output or Read since we are taking somthing out from the text file no? input make a fealing like somthing we are inserting in to the text file.
May be an stupid question, but this confusing me
Line Input-READING TEXT FILE- URGENT
I need some help here, i have a text file that looks like this:
Some lines are like this
1901931102951123 Some Text here
And some like this only numbers but no text.
12312121219
Now what I wish to do is, read the file...do line Input...and while reading the line if only numbers are found it shd discard it and if a line like this is found:
1901931102951123 Some Text here
then it shd record all those lines in another text file. Please help me writing the code.
Get Info From Certain Line In File With Open Filename For Input Etc Etc
I want to know if it is possible to get only certain info from a file. in example the file looks like this:
Hello
i
am
just
an
example
and
my
value
is
0
and
that
is
nice
and i only want to read if its value is 0 or 1 .... now i have to first skip every line until i get to the line with the 0 but is there a way to use something like
Input #1 line23 , a$
or something? :S
**RESOLVED** Line Input But No Carriage Returns In The File
I've got a file which I want to read in line by line, and for that I would normally use Line Input. But the file's lines are not separated by CR or CRLF which is what MSDN says Line Input needs. Instead, the first and second lines are separated by only a LF, all subsequent lines are separated by a LFLF pair. (I know this from looking at the data in a hex editor, where I see the x'0A' code which is chr10 or LF. There are no x'0D' chr13 CRs in the file at all)
Indeed when I use Line Edit in a Do..Loop and step thru' the program I can see it only goes thru' the loop once and thus treats the whole file as one line.
I had thought of using a stream edit approach to put the CRs in, but that might be unnecessary if anyone has a better idea?
Thanks...
File Input Treats Comma's As New Line! How CAn I Fixed.
Ok I Have A Text File Like This
8,1[11,1Last Seen:4,1
EST
]-[11,1Seen:4,1
11,1Times Today!8,1]
When I Read The File With The Input Command
Code:
Dim SettingsFile
Dim SettingsFileLocation
Dim a
SettingsFile = FreeFile
SettingsFileLocation = App.Path & "settings.txt"
Open SettingsFileLocation For Input As SettingsFile
Input #SettingsFile, a
DDEName.Text = a
It Messes Up Hardcore!
it thinks the , in the file means another line. how can i fix this?
Edited by - catacomb on 2/1/2004 8:42:18 PM
Skipping A Line In A Label, VIA Input Form File?
Hey guys,
Im trying to work out how i can write a string to a file, and then read it, and display it like..
"Hey,
Whats doing?
Regards,
John Doe"
Any ideas on how to make it skip down lines this way?
Cheers
Reading The Content Of A Text File Via Line Input, Backwards!
I am using Line input to read the content of a txt file into a listbox. As each line is read in, a function is called upon to check for something. It would be very helpful if I could read the text file in reverse, so the first line is read last.
Is there a way to do this?
Thanks!
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
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.
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.
Printing PDF From Selected Printer Input Tray
I need to print a pdf file using Visual Basic 6. I tried using: Shell(...Acrobat.exe /p /h "fileName"), and it work OK except that I can't control which input tray of the printer to be used.
Somebody, please help!
Filter Selected Keys From Keyboard Input Que.
Good day guys! It's me again and I need your help (again).
I have a project which requires me to hide both the desktop and the taskbar unless a valid security code was entered. This I succesfully coded (the codes actually came from a VB City neighboor). But still, pressing CTRL+Esc, ALT+Space, ALT+TAB and CTRL+ALT+DEL functions PERFECTLY WELL. Any user without a valid access code can start a program from the Start Menu, switch tasks and the most fearsome of all, terminate the Login Screen of my program.
Please help me. Relieve me of this miserable suffering and help my soul find its rest...
-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-
Who says VB is simple language?
Everyone is having trouble using it that you can fill a whole city full of confused VB programmers many time over.
Thus, the term VBCity.
-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-
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
Open Selected File With Selected Program
hi, i want a file i selected file to open with a program i selected.
i know how to run a program with shel
d = shell("path to program",vbnormalfocus)
but then it just opens the program without the file, is their a way i can get the file to open with the program i selected?
Selected Line Help With Text
in rtb this are the text;
>> means it is under the >
[>: Unfiled]
[>>: data 1]
data 1
[>>: data 2]
data 2
[>>: data 1]
idea 1
[>>: data 2]
idea 2
[>: Untitled]
[>>: data 1]
data 1
[>>: data 2]
data 2
[>>: data 1]
idea 1
[>>: data 2]
idea 2
[>: Unknown]
[>>: data 1]
data 1
[>>: data 2]
data 2
[>>: data 1]
idea 1
[>>: data 2]
idea 2
and i use this code;
VB Code:
Dim SelRecordID As Long Dim FoundPos As Integer With RichTextBox1 'Find the first selected record text if any. FoundPos = .Find("]", .SelStart, .SelStart + .SelLength) If FoundPos <> -1 Then 'Get physical record number location. SelRecordID = (.GetLineFromChar(FoundPos) 2) + 1 With frmDocumentNoteCards .ListView1.ListItems(SelRecordID).Selected = True .SelectedNoteCardColore End With DisplayNoteCardDetails 'details End If End With
'' just asking if how will i know if the first text start with "[>:" or second or third?
and how will i know if it is the first text start with "[>>:" under the "[>:"? or second or third??
kindly help me with this?
Edit: Added [vbcode][/vbcode] tags for clairty. - Hack
Cut Selected Line Only(specific)
--------------------------------------------------------------------------------
I cant seem to find how to simply select a certain number of lines, in a text.
Dim PadId As Integer
On Error Resume Next
PadId = Shell("Notepad MyFile", 1)
AppActivate(PadId)
'select and cut lines 1 thru x. ??? I already have the line counter x.
'paste elsewhere
'save file
'close file
Thanks in advance!
Highlighted A Selected Line In A Textbox
Hello,
I would like to know if it is possible to create a textbox in Visual Basic such that whenever I select/clicked on a certain line, I am able to highlight that whole line and know the contents of that line selected?
Sounds rather simple but seems quite complex to implement.
Thanks in advance!
Regards,
Joe
Placing Selected Line From DataGrid Into Textbox
All,
I am trying to place selected text from a datagrid into multiple textboxes. I can get data from first row of the datagrid without any problems, but I want to get the row that is selected. Any help would be appreciated.
J.
Changing The Colour Of A Selected Line In A Listbox
Does anybody know of a way to change the colour of the bar that appears over a selected item in a listbox?
Currently it's defaulting to the Windows colour but I would like to overide this with a colour of my own.
Additionally is it possible to overide the font colour of a selected item.
I've a feeling this is possible because I have an old program written in VB3 that seems to do this (unfortunatly I don't have the code - D'oh!).
Thanks in advance
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.
01153101522236000050035500000003350505212004@
01153101522236000050036300000005336305212004@
01153101522236000050346500000002404505212004@
01153101522236000050346300000001345205212004@
021531015222360000000013@
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.
|