So i am count after i find each string example when i find "ADT^A08" it counts how many found in the txt file and then it moves to the next file . My problem is that you can see totalA08 += 1 counts the amount. My problem is that it keeps its old value after each run so the first run cuonts 5000 and then the next count is 10000 . When that last file was the same as the first only 5000. Any ideas on how to properly clear that value after its done
thanks'
thanks'
VB.NET:
mports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Imports System.IO
Imports System.Collections
Imports System.Data.SqlClient
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
Dim fileListing As New DirectoryInfo("\\New Folder\")
Dim ifile As Integer
Dim strfile As String
For Each file As FileInfo In fileListing.GetFiles("*.*")
lstBoxFiles.Items.Add(file)
Next
ifile = 0
For ifile = ifile To lstBoxFiles.Items.Count - 1
strfile = "\\New Folder\" + lstBoxFiles.Items(ifile).ToString
Dim r As New System.IO.StreamReader(strfile)
While r.Peek <> -1
Dim filecontents As String = String.Empty
'add each line to the contents variable
filecontents = r.ReadLine
Dim A08count As String
Dim totalA08minus As Integer
Dim totalA08 As Integer
Dim A01count As String
Dim totalA01minus As Integer
Dim totalA01 As Integer
Dim BARcount As String
Dim totalBAR As Integer
Dim totalBARminus As Integer
Dim MSHcount As String
Dim totalMSH As Integer
Dim totalMSHminus As Integer
Dim subdate As String = filecontents
Dim subdatevalue As String
If filecontents.Contains(":2009") Then
subdate = subdate.Substring(subdate.IndexOf("2009") + 0, 8)
subdatevalue = subdate.ToString
End If
If filecontents.Contains("|ADT^A08|") Then
Dim foundindex As Integer = filecontents.ToString.IndexOf("|ADT^A08|")
A08count = filecontents.Substring(filecontents.IndexOf("|ADT^A08|"))
totalA08 += 1
totalA08minus = totalA08.ToString.Count - 1
End If
If filecontents.Contains("|ADT^A01|") Then
Dim foundindex As Integer = filecontents.ToString.IndexOf("|ADT^A01|")
A01count = filecontents.Substring(filecontents.IndexOf("|ADT^A01|"))
totalA01 += 1
totalA01minus = totalA01.ToString.Count - 1
End If
If filecontents.Contains("|BAR^P01|") Then
Dim foundindex As Integer = filecontents.ToString.IndexOf("|BAR^P01|")
BARcount = filecontents.Substring(filecontents.IndexOf("|BAR^P01|"))
totalBAR += 1
totalBARminus = totalBAR.ToString.Count - 1
End If
' adds all the data that was read from the streamreader to richtextbox1
Dim someText As String = filecontents
Dim strLen As Integer = someText.Length
Dim finished As Boolean = False
If r.EndOfStream = True Then
Dim typeString As String
Try
typeString = ListBox1.Items.ToString()
Catch ex As Exception
MessageBox.Show("Nothing was found there dummy " + ex.Message + "")
Return
End Try
Dim SQLStringMSH As String = "