| | |
text file manipulations
![]() |
•
•
Join Date: Mar 2007
Posts: 1
Reputation:
Solved Threads: 0
Hello to all vb community members,
I am quite new to vb6.0 and i am stuck on a little bit of problem,if any of u people can help me there,it would be wonderful and i will be thankful to u.
now the problem,
I have a textfile by the name 10117055.txt
This text file contains data in fixed format like
010110010001DD8 5073100507310001
010110010001ENAD 5073000507300001
010110010001ETV2 5073200507330001
010110010001ETV2 5073600507360001
010110010001ETV2 5073700508080001
010110010003ETV2 5073600507360001
010110010004GEMI 5111200511330001
010110010004SITMU5094200510590001
010110010004SITMU5113400511500001
010110010098DD8 50731005073100 1
010110010098ENAD 50730005073000 1
010110010098ETV2 50732005073300 1
010110010098ETV2 50736005080800 1
010110010098ETV2 50941005094100 1
010110010098GEMI 51112005113300
010110030001ENAD 5103600510460001
010110030001ENAD 5105200511170001
010110030001GEMI 5104800510510001
010110030001MAATV5104700510470001
010110030001NDT245111800511190001
010110030001POGO 5092400510070001
010110030001POGO 5100800510350001
010110030001SITMU5090500509060001
010110030001SITMU5090800509230001
010110030002ADITY5075200508000001
010110030002ADITY5181400518320001
And so on, now let me explain what these data means
the first 10 digit is homeid followed by the next 2digit which is memberid and the next letters are channelname,now channelname cannot be more than 5 letters.
so let me sum it up
0101100100 homeid 01 memberid and DD8 channelname.
now i want to give the count of all the unique channels that are watched by these homeid in a new textfile like this
suppose homeid 0101100100 has watched 10 unique channels then we have to have the data in a new text filein this format
0101100100 10
and so on for each unique homeid.like now after homeid 0101100100,we have homeid 0101100300,suppose it has watched 4 unique channels then my new textfile will contain
0101100100 10
0101100300 4
and so on
Here is a code that i have written
i m not able to get desired output,pls help
I am quite new to vb6.0 and i am stuck on a little bit of problem,if any of u people can help me there,it would be wonderful and i will be thankful to u.
now the problem,
I have a textfile by the name 10117055.txt
This text file contains data in fixed format like
010110010001DD8 5073100507310001
010110010001ENAD 5073000507300001
010110010001ETV2 5073200507330001
010110010001ETV2 5073600507360001
010110010001ETV2 5073700508080001
010110010003ETV2 5073600507360001
010110010004GEMI 5111200511330001
010110010004SITMU5094200510590001
010110010004SITMU5113400511500001
010110010098DD8 50731005073100 1
010110010098ENAD 50730005073000 1
010110010098ETV2 50732005073300 1
010110010098ETV2 50736005080800 1
010110010098ETV2 50941005094100 1
010110010098GEMI 51112005113300
010110030001ENAD 5103600510460001
010110030001ENAD 5105200511170001
010110030001GEMI 5104800510510001
010110030001MAATV5104700510470001
010110030001NDT245111800511190001
010110030001POGO 5092400510070001
010110030001POGO 5100800510350001
010110030001SITMU5090500509060001
010110030001SITMU5090800509230001
010110030002ADITY5075200508000001
010110030002ADITY5181400518320001
And so on, now let me explain what these data means
the first 10 digit is homeid followed by the next 2digit which is memberid and the next letters are channelname,now channelname cannot be more than 5 letters.
so let me sum it up
0101100100 homeid 01 memberid and DD8 channelname.
now i want to give the count of all the unique channels that are watched by these homeid in a new textfile like this
suppose homeid 0101100100 has watched 10 unique channels then we have to have the data in a new text filein this format
0101100100 10
and so on for each unique homeid.like now after homeid 0101100100,we have homeid 0101100300,suppose it has watched 4 unique channels then my new textfile will contain
0101100100 10
0101100300 4
and so on
Here is a code that i have written
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Option Explicit Dim fsys As New FileSystemObject Dim txtstream As TextStream Dim outstream As TextStream Private Sub cmdclick_Click() Dim j As Integer Dim searchline As String ' inputline to read txtstream Dim filename As String ' to dynamically generate filename Dim homeid As String ' to have homeid Dim prevhomeid As String ' to compare to homeid Dim channelname As String ' to store channelname Dim channelcount As Integer ' to count the numbers of unique channels Dim channelarray(0 To 100000) As String 'to store the homeid and channelname Dim prevchannelarray(0 To 100000) As String Dim csort As String 'Dim prevcarray As String Dim i As Integer For j = 0 To lstmarket.ListCount - 1 If lstmarket.Selected(j) = True Then If Len(Trim(txtyear.Text)) > 2 Or IsNumeric(Trim (txtyear.Text)) = False Then MsgBox "this should be 2 digit number " txtyear.Text = "" txtyear.SetFocus Exit Sub End If If Trim(txtweek) <= 9 And Len(Trim(txtweek)) < 2 Or IsNumeric(txtweek.Text) = False Then txtweek = "0" & Trim(txtweek) End If If Trim(txtday) > 7 Or IsNumeric(txtday) = False Then MsgBox "Please enter number which is equal to or less than 7" txtday.Text = "" txtday.SetFocus Exit Sub End If filename = lstmarket.List(j) & Trim(txtyear) & Trim(txtweek) & Trim(txtday) & ".swd" MsgBox ("you have selected the following" & filename) End If Next j '********main code for listing all the channels that the house id watch******* If fsys.FileExists("C:\rohit program\exercise\SWD\" & filename) = True Then MsgBox "file is open" Else MsgBox "file not found" End If 'prevchannelname = "" prevhomeid = "" channelcount = 0 prevchannelarray(k) = "" Set outstream = fsys.OpenTextFile("c:\channelcount.txt", ForWriting, True) Set txtstream = fsys.OpenTextFile("C:\rohit program\exercise\SWD\" & filename, ForReading, False) Do Until txtstream.AtEndOfStream searchline = txtstream.ReadLine homeid = Mid(searchline, 1, 10) channelname = Mid(searchline, 13, 5) channelarray(i) = homeid & channelname If channelarray(i) <> channelarray(i + 1) Then 'do nothing channelarray(k) = channelarray(i) If InStr(1, channelarray(i), channelname, vbTextCompare) = False Then channelcount = channelcount + 1 'outstream.WriteLine (channelarray(k)) outstream.WriteLine (channelarray(i)) & channelcount End If End If channelarray(i + 1) = channelarray(i) Loop MsgBox "process completed"
i m not able to get desired output,pls help
![]() |
Similar Threads
- connect to text file database (Visual Basic 4 / 5 / 6)
- Output in the text file (C)
- Create stats from a text file (Java)
- Store Bluetooth remote address to a text file (C++)
- 10 line text file (Java)
- Read and write to an ASCII Text file (Java)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: hiding progress bar of exporting chart
- Next Thread: MSCOMM Limitations
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





