Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21096

Missing Records from scanned file

$
0
0
This is a combination of 2 routines used to generate and retrieve records of lab tests.

this code retrieves the numbers to be compared to Attachment 97117 and stores them in text.txt

Code:

Private Sub Command1_Click()
Open "a:\labstuff.txt" For Random As #1 Len = 256
Open "c:\test\text.txt" For Output As #2
Dim xx As String * 256
Get #1, 2, xx
For jj = 0 To 44
x$ = Mid$(xx, 4 * jj + 3, 1)
y$ = Mid(xx, 4 * jj + 4, 1)
lT = Asc(y$) * 256 + Asc(x$)
Print #2, lT
If lT = 0 Then Exit For
Next
Close #1
Close #2
End Sub

this code generates the sentences pulled from Attachment 97117 in the file output.txt

Code:

Private Sub Command1_Click()
Dim FileA As Integer
Dim FileB As Integer
Dim Outputfile As Integer
Dim i As Long
Dim j As Long
Dim Readinteger As String
Dim Readtext As String
Dim Outtext As String
Dim tmpInteger(5000) As String
Dim tmpText() As String
FileA = FreeFile
Open "c:\test\text.txt" For Input As #FileA
FileB = FreeFile
Open "c:\med\p1tx.txt" For Input As #FileB
Outputfile = FreeFile
Open "c:\test\output.txt" For Output As #Outputfile
Dim x As Integer, numLines As Integer
Do While Not EOF(FileA)
Input #FileA, Readinteger
tmpInteger(x) = Trim(Readinteger)
x = x + 1
Loop
numLines = x - 1
Outtext = ""
For i = LBound(tmpInteger) To numLines - 1
    Close #FileB
    Open "c:\med\p1tx.txt" For Input As #FileB
    Do While Not EOF(FileB)
    Line Input #FileB, Readtext
    tmpText = Split(Readtext, ",")
    If tmpText(0) = tmpInteger(i) Then
        Outtext = Outtext & " " & tmpText(1) & vbCrLf
       
        If UBound(tmpText) > 1 Then
            For j = 2 To UBound(tmpText)
                Outtext = Outtext & " " & tmpText(j) & vbCrLf
            Next
        End If
        Exit Do
    End If
    Loop
Next i

Print #Outputfile, Trim(Outtext)
Close #FileA
Close #FileB
Close #Outputfile
End Sub

this is the text.txt file generated by the first routine
Quote:

5021
8000
8004
8400
8005
8006
273
8076
630
580
8087
620
8102
104
8115
50
60
8126
40
491
640
665
950
900
8196
494
8209
6240
0
this is the output.txt generated

Quote:

@ >You received counseling regarding preventive health.\
@ >Diagnostic data was reviewed for preventive health.\
@ >Lab results were reviewed.\
@ >We reviewed your patient concerns regarding preventive health.\
@ >A Preventive Health Plan was reviewed.\
E >Today we reviewed Nutrition diagnostic data.\
F >Today we reviewed Metabolic System diagnostic data.\
G >Today we reviewed Endocrine System diagnostic data.\
H >Today we reviewed Immune System diagnostic data.\
I >Today we reviewed Blood System diagnostic data.\
O >Today we reviewed Digestive System diagnostic data.\
P >Today we reviewed Genito-Urinary System diagnostic data.\

after comparing the input with the output it appears than all non 4 digit coded lines are not read into the output.txt file from the p1tx.txt attached

for example 8004 is read but 273 is not

What changes can / shuld be made to get the missing lines?
Attached Files

Viewing all articles
Browse latest Browse all 21096

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>