Click here to Skip to main content
15,877,915 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Could someone please assist here? I have a program that reads a text file and copys the contents separated by a $ sign and writes the details to another new text file excluding the $ Sign. What I need assistance is to do a count and get the total records separate by the $ sign. Eg. ajasasaj$testing%878788%%$lkshhajsjah
for the above the total count would be 3. What I want is the 3 value. so how could I get that 3? Please assist at your earliest.

Dim WordsCount as integer
sFilename = "C:\Listview.txt"
If Dir(sFilename.ToString) <> "" Then
	sFileReader = System.IO.File.OpenText(sFilename)
	sInputLine = sFileReader.ReadLine()
	Do Until sInputLine Is Nothing
		sInputLine = sFileReader.ReadLine()
		WordsCount += sInputLine.Split(",").Length
End If

Happy Coding!
Share this answer
ekipongi 21-May-13 20:01pm    
Thanks Aarti for the reply. Didn't tried your code but I guess it would work. Thanks anyway.
try this..this will give you what you want but if you are already separating from $ sign why dont you increment the counter there only
Dim FileReader = New StreamReader("D:\New Text Document.txt")
Dim line As String
Dim count As Integer
line = FileReader.ReadToEnd()
For Each alpha As Char In line
    If alpha = "$" Then
        count += 1
    End If
Share this answer
ekipongi 21-May-13 20:00pm    
Thanks Basmeh. Modified your code and got what I wanted. Thanks

now Could you please assist here again? now I want to check a specific value (:32B:) in a text file that contains millions of data and get the values (actual figures/amounts) excluding the currency. E.g. check if :32B: is found in the file and if it is found then grab the next value after this, which would be the amount. In essence it would be like :32B:JPY12561694,00
So pull out the 12561694,00 excluding the comma. So the actual data that I want to get is 1256169400
Basmeh Awad 22-May-13 6:56am    
ok there is a solution post this as a question...and add a reply here that u posted
Basmeh Awad 22-May-13 4:53am    

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900