473,563 Members | 2,364 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

multiple opening of text files in vb6.0

25 New Member
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 7250
vijaydiwakar
579 Contributor
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 New Member
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 FileSystemObjec t
Dim txtstream As TextStream
Dim outstream As TextStream
Private Sub Command1_click( )

Dim j As Integer
Dim masterfile(1100 000) 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.ListC ount - 1
If lstmarket.Selec ted(j) = True Then

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



If Trim(txtweek) <= 9 And Len(Trim(txtwee k)) < 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\exercis e\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.OpenTextFi le("c:\Masterfi le.txt", ForWriting, True)
Set txtstream = fsys.OpenTextFi le("C:\Rohit program\exercis e\SWD\" & filename, ForReading)
Do Until txtstream.AtEnd OfStream
masterline = txtstream.ReadL ine
mastercount = mastercount + 1

masterfile(mast ercount) = masterline

For mastercount = 1 To mastercount - 1
outstream.Write Line (masterline)
Next mastercount
Loop
End Sub
Feb 28 '07 #3
Killer42
8,435 Recognized Expert Expert
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 New Member
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
12025
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 on the server (in our own accounts on the same machine). When I am testing both versions of our program using the same browser (IE on Windows or...
7
3182
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 message when I try to do another window.open. Any suggestions are welcomed. Evan Kontos | EKontos@comtekcadd.com 27 Whitehall St. | 3rd Floor |...
12
1566
by: Berj | last post by:
i have a novice question. is Access multi-user? can multiple users access the same database?
2
2170
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 to get all the CS files to edit so that i can see all the files opened. Thanks Senthil
0
1908
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 (registry: *.*\shell\myprogram\command(valu of the comand key is "...\myprogram.exe" "%1") context menu, so tha when you select multiple files, the paths...
6
4971
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 for long running reports. When the processing is complete it uses crystal reports to load a template file, populate it, and then export it to a...
15
15062
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 the output file but this is tedious. Imagine typing 1000 filenames...is there a efficient way to do this?? Thanks
3
5674
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 //Propagation constants are elements of the vector beta for(int j=0;j<(int)(number_of_nodes);j++){ if(*(beta+j)>substrate*k && *(beta+i)<core*k){...
10
3665
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 "single" file with my app which works to get commandline arguments to get file paths: Dim cla As String() = Environment.GetCommandLineArgs() If...
2
4086
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: 10212009 12 34 56 25 67 90 End Set ******** Set: 2 Date: 10222009
0
7658
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7630
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5201
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3628
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3612
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2077
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1194
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.