Lists & Text Files
How can I make it add a item in a list for each line in a text file.
EX: Text File has: A new bike A new motercycle A new car
Then I want list to read and have: 1st line: a new bike 2nd line: a new motercycle 3rd line: a new car
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Creating A Text File That Lists Files And Timestamps
I am copying files from one machine to others and I have a .txt file that I want to list the files that were copied. How would I do that?
Rem write
Open "c:update.txt " For Output As #1
Print #1, ????
Close #1
Is there a way to list every file is the folder that I am copying from and write that to the c:update.txt?
Thank You
Vbscript That Lists All Files
Hi,
I need a vbscript that will lists all of the files with a .txt extension in a given directory. COuld anyone please help me by pointing out the command or function that I need. Or any other ideas would help.
Thank You,
Laura
Drives, Files And Directory Lists.
Can someone please tell me whats wrong with this code??!!
Option Explicit
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub directoryList_Change()
'update file list box to synchronise with the
'directory list box
fileList.Path = directoryList.Path
End Sub
Private Sub driveList_Change()
On Error GoTo DriveHandler
'if new drive was selected, with the directory
'list box
directoryList.Path = driveList.Drive
End Sub
'if there is an error, reset driveList.drive
'with the drive from the directoryList.path
DriveHandler:
driveList.Drive = directoryList.Path
Exit Sub
Private Sub Form_Load()
fileList.Path = CurDir
directoryList.Path = CurDir
driveList.Drive = CurDir
End Sub
Its saying that "Label not defined" and is highlighting the 'On Error GoTo DriveHandler' line of code in the driveList_Change procedure.
This Functions Lists Files, But Not Folders
VB Code:
Private Function AllFiles(ByVal FullPath As String) _ As String() Dim oFs As New FileSystemObjectDim sAns() As StringDim oFolder As FolderDim oFile As FileDim lElement As Long ReDim sAns(0) As StringIf oFs.FolderExists(FullPath) Then Set oFolder = oFs.GetFolder(FullPath) For Each oFile In oFolder.Files lElement = IIf(sAns(0) = "", 0, lElement + 1) ReDim Preserve sAns(lElement) As String sAns(lElement) = oFile.Name NextEnd If AllFiles = sAnsErrHandler: Set oFs = Nothing Set oFolder = Nothing Set oFile = NothingEnd Function Private Sub Form_Load()Dim sFiles() As StringDim lCtr As LongsFiles = AllFiles("C:Documents and SettingsHomeMy Documents")For lCtr = 0 To UBound(sFiles) Debug.Print sFiles(lCtr)NextEnd Sub
Anyone know of a way i can make it lists the folders too, in that direcotry?
Lists To Text
Hi i was wondering about 2 things.
First: can you have a left to right scrol bar on a list box?
Second: Can i export the data from the list to a text file.
Thanks a lot
Lists -> Text Boxes
Hi,
I'm relatively new here, and just wondering how I could go about pasting an item from a list into a text box. I'm working on a specialized text editor, and it's fully functional as-is, but I'd like to add this, because this project's designated audience ( IRC scriptors, if you must know <g> ) uses a lot of the same words/phrases, and I'd like to make it a matter of double-clicking the item you want to paste it into the text editor; also handy when you don't know exactly what you want.
InnerChylde
Adding Text To Combobox Lists
I have a combobox in my program. Under -list- it already has 4 movies.
What I want to do is to add a textbox that a user can use to type in names of other movies and then he/she can hit an "add" command button and this will add the text typed from the textbox into the list.
Does anyone know what the code would be for this?
Comparing Two Text Lists - RESOLVED
I have a program that imports a comma delimited text file into a database. In an effort to prevent bad data from getting updated, I want to validate the incoming file before processing. It shouldn't be too bad, since the incoming file has the first line with the field names, for example: "firstname","lastname","title".
In my program I have a list of the field names, in the correct order. For example, "lastname","firstname","ssn","title".
I can easily check the first line of the file and see if it matches, but what my users want is more detail if it doesn't. Using the above examples, it should flag that the incoming file is missing the "ssn" field. And it should also indicate that while the "firstname" and "lastname" are in both lists, they are in a different order.
So this is not just a matter of "does an item exist in another list", but "is it in the same position?"
I've searched and found many posts related to comparing lists, but not as fussy as my users are.
I figure the first step is to parse the two lists into arrays, so I have:
VB Code:
a(0) = "firstname" b(0) = "lastname"a(1) = "lastname" b(1) = "firstname"a(2) = "title" b(2) = "ssn"a(3) = "address1" b(3) = "title"a(4) = "address2" b(4) = "address1"a(5) = "city" b(5) = "address2"
and I figure I need to go through each array, checking if the value exists in the other array.
Any tips / pointers are appreciated.
Steve
vb6
Using Custom Resource Files - Text Files (RESOLVED)
Hi
In my program i have a file, say readme.txt, that contains alot of information about the program. When i create a newer version of my program, i would like to just distribute the exe file and not the readme.txt file ( which would also be updated ).
So the way i thought of doing this is adding it in a resource file, so when i compile, the readme.txt is compiled into the exe.
Now the only problem i have is that i dont know how to retrieve the data from the readme.txt file thats stored in the resource file.
I assume its something like this
VB Code:
text1.text = LoadResData("IDName", ? )
but i dont know what to put in the second parameter, the only constants i can use are
vbresBitmap
vbresCursor
vbresIcon
and none of them are obviously it
or am i doing this wrong?
Thanks
Deleting Text Files Or Text From Files!
If you've never used the Kill statement before, the following are needed for this to work properly :The Path to the fileThe full file (the extension is important here)The string of the file must be enclosed with double quotesSo, for the above :
Code:
Kill "c:my documentsfile.txt"
Should do the trick.
The following will check if the file exists, if it's open, then will kill it :
Code:
Select Case Len(Dir$("c:my documentsfile.txt"))
Case 0
Msgbox "Where'd it go - no file found here !"
Case Else
If (Open "c:my documentsfile.txt" for output as #1) = 0 then
Msgbox "The file's already open, what're you playing at ?"
Else
Close #1
Kill "c:my documentsfile.txt"
End If
End Select
Binary Files Are Just ASCII Text Files... Why?
I have very little dealings with reading/writing files using binary access. I've always used simple Input/Output as I've only had small tasks to do with files.
I have read many times that when you write out raw binary data to a file and open it up, it looks like a bunch of gibberish. I'm not seeing this.
Here is some sample code of what I'm doing
Code:
Dim x As Long
Dim b(1 To 1000000) As Byte
Dim ff As Long
ff = FreeFile
For x = 1 To 1000000
b(x) = Int(Rnd * 255)
Next
Open "c:inary.txt" For Binary As #ff
Put #1, 1, b
Close #ff
Again, just sample code... what I am really doing is writing my game map data to a file. I put it in a byte array just like b() is.
However, when I open this file up in my text editor, I see everything in ASCII characters.
What happened to the "gibberish" I am supposed to be seeing?
If I did this for example instead
Code:
b(x) = Int(Rnd * 26) + 65
I would see all capital letters when I viewed the file.
Subsequently I am reading the file into my byte array like this sample code
Code:
'Fill the temp array with the file contents
Open "c:inary.txt" For Binary As #ff
ReDim b(LOF(ff))
Get ff, , b
Close #ff
Am I missing something, or is what everyone calls "gibberish" just random ASCII characters they see?
I also write other files that contain mostly text (which I convert to byte arrays). These open as plain text files which are easily readable.
Any input of how I can write "bytes" to files that dont show up as ASCII when opened with a text editor?
Thanks
Importing Excel Files Or Text Files
When I attempt to import any excel file or text file into access, I receive an error message "Active X component can't create object". Now before I have done this function several times with complete success. However something has changed in my program which is now preventing from acclomplishing this function. Help.
Processing Text Files (FINDING AND REPLACING DATA INSIDE A TEXT FILE)
Hi
I would appreciate if some one help me out in finding an answer to this.
I am a new user of visual basic and have been stuck in writing a code / project for finding and replacing a data from a text file ( input file to an application).
The part of file sample which need to be replaced is below
SCJ 1 NAME "" TYPE FIXED_TIME CYCLE_TIME 61.0 OFFSET 0.0
SIGNAL_GROUP 1 NAME "" SCJ 1 RED_END 2.0 GREEN_END 26.0 TRED_AMBER 0.0 TAMBER 4.0
For example I need to replace 61.0 to 91.0 and 26.0 to 43.0.
The data in file is random and can come at any line number, one of my other concern is how to locate the line number, I have no clue for that.
Please help me in working this out.
Best Regards
Abdy
*RESOLVED* Using Text File As String Input For Opening Other Text Files
OK, I've been banging my head trying to get this one little piece to work (that I had working prior to a loss of power on Friday) but I cant remember the syntax I used to get it right.
What I'm doing is opening 1 text file and using it as the input in a loop to open and parse mutiple text files to a text box.
Heres the part that doesn't work;
Code:
Open "rbt.txt" For Input As 1
Do Until EOF(1)
Open " " & rbt.txt & ".txt" For Input As 2 'THIS IS THE PART THATS not working !
Line Input #2, slist
s = s & slist & vbCrLf
Upt_log_txt.Text = s
Loop
I know its a syntax (read as placement) issue but I cant get the right combo down.
HELP !
Newbie-Opening And Saving Text Files In Text Boxes
I'm trying to find a way to save text from a text box as a .txt file or .rtf and then be able to retrieve files of similar type and open them in a text box on my program. There must be a way to do this, I'm just not able to figure it out. Help?
Remove Text Controls From Text Files *Resolved*
I have an application the reads a fixed field/length text file (.txt) via FSO and TextStream.ReadLine. It has a record length check that fails sometimes because of line feeds. I'm using:
strTextLine = Replace(strTextLine, vbCrLf, " ")
strTextLine = Replace(strTextLine, vbCr, " ")
strTextLine = Replace(strTextLine, vbLf, " ")
but I'm still getting length errors occasionally. Are there more to check for then this? Is there a better way?
The field causing me problems is text from an outside application that allows the users to enter in freeform text.
Thanks!
Someone told me there was a vbTab and I also needed to pad with two spaces instead of one for the vbTab to make up for it being removed. The rest are one byte.
Seems to be working fine now.
Help Splitting Text File Into Numerous Text Files
Please Help!!!
I have a large text file which containts a few thousand lines which are seperated by unqiue headers. The number of lines between these headers belong to that header. I want to be able to import this large file normally 2MB in size and based on each of the headers, split the file into a number of smaller files based on the headers and give the file name the name/number of the header.
This is how the file looks if you paste it into notepad:-
11101H 05/0600003
11101S 000ES1110100101E 01ABCDEF 26040542B0100000778.86SALARIES 111111A M Jamesons 735
11101S 000ES1110100101E 01ABCDEF 26040542B0100000889.57SALARIES 222222A A Jamesons 736
11101S 000ES1110100101E 01ABCDEF 26040542B0100001144.75SALARIES 333333A H Jamesons 738
11292H 05/0600007
11292S 000ES1129206291E 01ABCDEF 26040542B0100000028.67SALARIES 444444I T SMITH 23641
11292S 000ES1129206291E 01ABCDEF 26040542B0100000062.57SALARIES 123456A CM SMITH 23642
11292S 000ES1129206291E 01ABCDEF 26040542B0100000120.32SALARIES 221122A SP SMITH 23643
22021S 000KA2202106301E 01ABCDEF 26040542B0100000183.78SALARIES 999999D J JONES 34187
22021S 000KA2202106381E 01ABCDEF 26040542B0100000013.36SALARIES 000000D J JONES 34479
22021S 000KA2202106601E 01ABCDEF 26040542B0100000268.15SALARIES 212121A C JONES 24500
22021S 000KA2202106681E 01ABCDEF 26040542B0100000005.32SALARIES 111111A C JONES 24734
22051H 05/0600007
22051S 000KA2205100181E 01ABCDEF 26040542B0100000128.65SALARIES 776688A D EASTWWOOD 9093
22051S 000KA2205100191E 01ABCDEF 26040542B0100000069.08SALARIES 554433A DR EASTWWOOD 14197
22051S 000KA2205100191E 01ABCDEF 26040542B0100000084.04SALARIES 342234A AJ EASTWWOOD 14198
22051S 000KA2205100191E 01ABCDEF 26040542B0100000180.88SALARIES 000000A D EASTWWOOD 14199
22051S 000KA2205100401E 01ABCDEF 26040542B0100001455.75SALARIES 998877A M EASTWWOOD 23796
22051S 000KA2205100411E 01ABCDEF 26040542B0100000146.14SALARIES 222223A M EASTWWOOD 23986
22051S 000KA2205100481E 01ABCDEF 26040542B0100000109.21SALARIES 879421A M EASTWWOOD 24179
There are three headers in this file which means the program should produce three seperate text files based on the header names i.e.
11101H 05/0600003
11292H 05/0600007
22051H 05/0600007
The file names will be called 11101, 11292 and 22051 respectively and the 05/060003 etc.. will be included in each file created as this states the number of records in each file and thje 05/06 is the year identifier....
Any ideas how I can do this??????
Combining Files To Together (TEXT Files)
Hi, guys got a small problem, were I need to combine all these text files in a specific folder into one big text file, using visual basic. The names of these text files vary eg. "01Dec.08.00" or "03Dec.16.00", as you may see they will be all .00 files. I would like with the push of a command button, combine all these .00 files (no matter how many files or actual names, they will always be .00 files though!) in this specific folder into one .asc file or .txt file to be saved in another specific folder.
Currently i have a batch file that can do this and its code for it is as follows if it helps at all:
Code:
copy c:aaComGodata.00 c:aaComGodataA.00
copy c:aaComGodataA.00 +c:aaComS1*.*
COPY c:aaComGOdataA.00 c:aaComGOdataA.asc
Form the code above, all the combined data is saved into dataA.asc.
Ive tried to explain my situation as much as possible, if neccassary will provide more information, but if anyone can help it would be very much appreciated
Thnx, Boz
Catch Up Text (Merging Text Files)
I am developing a program that will compare two text files and fill in what one text file doesn't have. For example:
[Text file 1]
Hello
world
[Text file 2]
Hello there,
Hello again
world
I would have the program check each text files. If they aren't the same then make them the same. So it would compare each text file line by line, and if there is something in between two lines that isn't there in one text file it would put it there. And if there's something after a certain word than it would add it based on the line numbers. Here's some pseudo code:
(Program scans the line)Hello
(Program scans the line)Hello there,
(Program decides whether the line numbers are the same and adds "there," since they are)
(Program scans the line)world
(Program scans the line)Hello again
(Program decides whether the line numbers are the same and tries to find similarites in files)
(Program scans the line)world
(Program determines "Hello again" belongs in between Hello and world)
(Program determines that the file has ended)
How could I do this? Heh, I'm not very sure...
Text Files To Display In Text Boxes
I have a text file, how do I display the ENTIRE text file into a text box? does the text box have the properties to allow for word wrapping and having a scroll bar as needed? Thanks
Creating Text Files And Saving Text To Them.
This is the best I can find to create a textfile and save a string variable's contents to it. Logically it doesn't make sense to me since you would first need to "create" a file before "opening" it, so either I just don't get it, or this is wrong.
Either way, it's not working, and generates the error: Run-time error '52': Bad file name or number
What am I doing wrong?
CODE'Saves to Text File
Dim strUserText As String
strUserText = "This is a bunch of text to save in a textfile."
Open "c:ProgramLogsLog_" & Date$ & ".log" For Output As #1
Print #1, strUserText
Close #1
Open Text Files In Text Box
I want to open a text file in a text box but something is not right, I get an error message saying "file not foud"
This is the code that I have:
Private Sub File1_Click()
Dim file As String
Text2.Text = File1.FileName
file = Dir1.Path & "" & File1.FileName
Open "file" For Input As #1
Do Until EOF(1)
Line Input #1, LineOfText$
AllText$ = AllText$ & LineOfText$ & Wrap%
Loop
Text1.Text = AllText$
Close 1
End Sub
Using Lists
apologies if this is very basic, but i have only started using vb on monday and am doing a new project for my company using it.
my problem is that i am using a button on my form (in access) which will call a new form with a list of items, of which one can be selected. when the 'select' button is pressed, i need to be able to retrieve the selected item (basically just the text item in the list).
first off, i'm having trouble with setting up the program to show the items in the list - the form (named "selectfinger") is appearing but then it crashes before displaying any items:
DoCmd.OpenForm ("selectfinger")
Forms!selectfinger.List1.addItem ("Right Index")
Following this, i anticipate not knowing exactly how to retrieve the required bit of data back to the starting code.
any help much appreciated...
Lists
i have a list and a lot of dates in.i want to choose from another combo a month and a year and show me all the dates of that month and year that are listed in my list
Help With Lists
If I have a list of names in one column and times in the next 7 columns, how can i merge the identical names and times into one row. Think of it as a schedule, where Tom is listed three times. I want him to be listed once with all the data from the three rows combined into one row.
Any Ideas?
Insu
A Need Better Lists!
I was wondering HOW you make the "detailed view" lists that are in windows in vb? is it possible?
(see attachment for image)
/Thanks
2 Lists
hi, i have 2 listboxes together. 1 for urls and the other for numbers. i have made it so that when you click 1 it will highlight the value that goes with it on the other one. how do i make them scroll together though?
Lists
Hi its me again.I add some data into a list and them saved them in a txt file.When i am going to load them appears only the first into the list.How can i load all of them?
Using Lists
Could someone possible help me with this.
I am opening a file for append as filenum
How can I get the variables in the file into a listbox on the following form?
Lists
Does anyone know how to create a list then add things to the list and then delete them again?
like lets say you have a text box a listbox and 2 command buttons in the text box you have apple one command button adds it to the list and the other takes a selected item on the lists and deletes it from the list.
you know what im saying??
Lists
Hey all, im having trouble....i have a list box and a common dialog...i use the common dialog control for the show open command......and well when i use this code it doesn't multi line in the list box.....you see it brings up a bunch of names inside the list box..i want them to scroll down and well it just moves them right and puts the wierd little bold symbols like this:| except bold and theres 2..and well i want them to scroll down not to the side....can anyone help??
LISTS, HELP!!
Ok heres my problem I have a list, and im able to add things to this list but I cannot get the list to remove the "selected item" how would I do this?
-Lemnas-
_______________________
www.imladris.homepad.com
Lists
I have been learning vb since the semester started and i am wondering how i would put a list in a label box. I need to put each list in each control variable like:
strbat(0) = "the list"
strbat(1) = "another list"
I cant seem to get the list in the quotes! HELP!!!
Lists?
How can i say what you've selected in my list?
So when you presh CmdApply some variable will be what you selected?
Thx already
Using Lists
Hey, im going to use a list as a playlist on a little app im making to play songs using the windows media player control, I want to show the ID3 tag on the list but when it is clicked i want it to play, how could i show the ID3 tag of the file if it has one and be able to store the file location without it being seen on screen?
Using Lists In Vb
how would i use a list to perform certain actions?
i.e. if list1 ontained the letters "a","b","c","d","e","f","g", how would i make a label (label1) display different text for each letter?
Lists
Ok im trying to do this. I want to have a list of names, ie List1
rick
dave
chris
paul
scott
then have a textbox called text1 where u can enter a word such as Iam then click a button and it will change all the words in List1 to
iamrick
iamdave
iamchris
iampaul
iamscott
and do the same for after the name such as
rickrules
daverules
Any ideas people?
Lists
Complete newbie
Ok so have this list box and 3 text boxes
i want to be able to click a comand button and the contents of the text boxes are stored as one item in the list box
e.g
List Box
Text1 Text2 Text3
So far i can only get one item....
if any of that has made sense please does anyone have an answer...
Lists...
I got a couple of questions on list controls.
There is an additem method which adds an item to a list.
I want to be able to highlight an item from a list and delete it...
how do i go about doing this?
Also my second question is how do I get the count of the list items
is it just Me.lst.Count?
For instance
For i=0 to Me.lst.Count-1
EmailSend.Attachments.Add(Index of list)
Next i
..
Also how do I index the list?
Thanks in advance,
Jon
Lists
hey
i have a general question...why would any self respecting person use linked lists in programs, and if there is a reason...what benefit would it have, especially when u could use trees? or were they created only because they could be?
Lists
how do you get two lines from a file to appear in a list....(I have to make a highscores list so i need one column for a name and another column for the score)
Lists..
I'm creating a program that needs to select an item from a list on another window, I got that working fine BUT, now i'm trying to get the text from the selected item and that's where my problem lies. Any help guys? Thanks..
Lists
Help,
How do you remove duplications from a list box?????
Lists
How can I sort lists in descending order? and how do i save a list's contents to an ini?
|