473,325 Members | 2,816 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,325 software developers and data experts.

multiple opening of text files in vb6.0

25
Hi guys,

I have a problem regarding a txt file operations.I have a listbox which has
various 3 digits numbers.there are 2 txtboxes on my form .now suppose if
check 101 from check box and write 1 and 7 in txtboxes i should be able to open all the files having the numbe 10117.
to inform u guys the files are txtfiles having names

10117051

where101 is market no 17 is the year and 05 is week and 1to 7 may be day

so i mean there are 7 files 10117051
10117052
10117053

and so on till 10117057


i need to copy all the contents of this file into a new single file.

If naybody caN HELP ME ,IT WOULD BE A GREAT HELP.
Feb 27 '07 #1
4 7221
vijaydiwakar
579 512MB
Hi guys,

I have a problem regarding a txt file operations.I have a listbox which has
various 3 digits numbers.there are 2 txtboxes on my form .now suppose if
check 101 from check box and write 1 and 7 in txtboxes i should be able to open all the files having the numbe 10117.
to inform u guys the files are txtfiles having names

10117051

where101 is market no 17 is the year and 05 is week and 1to 7 may be day

so i mean there are 7 files 10117051
10117052
10117053

and so on till 10117057


i need to copy all the contents of this file into a new single file.

If naybody caN HELP ME ,IT WOULD BE A GREAT HELP.
yes u can for that use directory ctrl give the path to it then it will give u entire list of files apply mid$ function to filenames if it matches then open it
try it by ur self
Feb 27 '07 #2
Ronin
25
yes u can for that use directory ctrl give the path to it then it will give u entire list of files apply mid$ function to filenames if it matches then open it
try it by ur self


Here is a piece of code i have written for it
Option Explicit
Dim fsys As New FileSystemObject
Dim txtstream As TextStream
Dim outstream As TextStream
Private Sub Command1_click()

Dim j As Integer
Dim masterfile(1100000) As String
Dim masterline As String
Dim iday As Integer
Dim mastercount As Integer
For iday = 1 To 7
mastercount = 0


For j = 0 To lstmarket.ListCount - 1
If lstmarket.Selected(j) = True Then

If Len(Trim(txtYear)) > 2 Or IsNumeric(Trim(txtYear)) = False Then
MsgBox "There should be a 2 digit number"
txtYear.Text = ""
txtYear.SetFocus
Exit Sub
End If



If Trim(txtweek) <= 9 And Len(Trim(txtweek)) < 2 Then
txtweek = "0" & Trim(txtweek)
End If
filename = lstmarket.List(j) & Trim(txtYear) & Trim(txtweek) & iday & ".txt"
MsgBox ("You have selected the following file" & filename)

End If
Next j
Next iday

If fsys.FileExists("C:\Rohit program\exercise\SWD\" & filename) = True Then
MsgBox ("The files are opened for manipulation")
Else
MsgBox ("File not found")
End If



*********** the main coding starts from here*************

Set outstream = fsys.OpenTextFile("c:\Masterfile.txt", ForWriting, True)
Set txtstream = fsys.OpenTextFile("C:\Rohit program\exercise\SWD\" & filename, ForReading)
Do Until txtstream.AtEndOfStream
masterline = txtstream.ReadLine
mastercount = mastercount + 1

masterfile(mastercount) = masterline

For mastercount = 1 To mastercount - 1
outstream.WriteLine (masterline)
Next mastercount
Loop
End Sub
Feb 28 '07 #3
Killer42
8,435 Expert 8TB
I kind of like vijaydiwakar's suggestion. The FileListBox control will be useful for this. Just plug in the Path, and the Pattern (that's the filename with wildcards) and it will list all the matching files - then you just run through the list and read each file.
Mar 1 '07 #4
Ronin
25
I kind of like vijaydiwakar's suggestion. The FileListBox control will be useful for this. Just plug in the Path, and the Pattern (that's the filename with wildcards) and it will list all the matching files - then you just run through the list and read each file.

no probs a little bit of thinking and i got the code done.here is a sample piece of my code

*** it is just a part of my code that selects all the 7 files and write that into the master file*********************
Expand|Select|Wrap|Line Numbers
  1. For j = 0 To lstmarket.ListCount - 1
  2.     If lstmarket.Selected(j) = True Then
  3.         Set outstream = fsys.OpenTextFile("c:\masterfile.txt", ForWriting, True)
  4.              For iday = 1 To 7
  5.                 filename = lstmarket.List(j) & Trim(txtYear) & Trim(txtweek) & iday & ".swd"
  6.                 If fsys.FileExists("C:\Rohit program\exercise\swd\" & filename) = False Then
  7.                     MsgBox "file does not exist"
  8.                     Exit Sub
  9.                 End If
  10.                 Set txtstream = fsys.OpenTextFile("C:\Rohit program\exercise\swd\" & filename, ForReading)
  11.                     Do Until txtstream.AtEndOfStream
  12.                         masterline = txtstream.ReadLine
  13.                         outstream.WriteLine (masterline)
  14.                     Loop
  15.                 txtstream.Close
  16.             Next iday
  17.         outstream.Close
  18.     End If
  19.  Next j
  20.  
  21.  MsgBox "completed"
Mar 2 '07 #5

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

Similar topics

13
by: jing_li | last post by:
Hi, you all, I am a newbee for php and I need your help. One of my coworker and I are both developing a webpage for our project using php. We have a copy of the same files in different location...
7
by: Evan Kontos | last post by:
I am using the window.open function to open a small window and I am using GET to get values back from that window. I want to be able to open another from the second window but I get an error...
12
by: Berj | last post by:
i have a novice question. is Access multi-user? can multiple users access the same database?
2
by: SenthilVel | last post by:
HI all in my visual studio DOtnet . i am not able to open multiple cs files in the projects , its openings only one cs file at a time, can any one let me know, what setttings i must do in order...
0
by: vinX | last post by:
Ok, i am making a file renaming utility, you can add filesize (in MB o KB), filepath, creation date and/or time, a counter, parent folder, th original name etc... I put the program in the...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
15
by: leorulez | last post by:
Is there any way to read multiple files (more than 1000 files) and then write into one single output file using C? Right now in my program, I have a loop which asks for the filename and writes into...
3
emaghero
by: emaghero | last post by:
Hello all, I want to open multiple txt files with similar names in C++ I have attempted this with the following code //Create as many txt files as there are valid propagation constants...
10
by: kimiraikkonen | last post by:
Hi, I have an app which has a listbox and when i double click an associated fileS, i want their paths to be added into listbox in my application. This code works good when i try to open a...
2
by: rka77 | last post by:
Hi, I am trying to make a Python2.6 script on a Win32 that will read all the text files stored in a directory and print only the lines containing actual data. A sample file - Set : 1 Date:...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.