• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 158
  • Last Modified:

how do i see the below data ?

i has 1 file which inside it like the below.

01012000  john032 male  02012000  richard45 female  03012000  samy060  male


above is contains 3 data .the first data is from "01012000 john032  to male   and the second data starting from "02012000 richard45 to female"

the problem is if im using my own code it just can display  me the first data only and the second plus third wont show. so whats the code to give me away that i can display the second data after the first data.



pls
0
JOHNHO
Asked:
JOHNHO
  • 8
  • 4
  • 2
  • +1
1 Solution
 
samopalCommented:
How do you want to display data?
0
 
Éric MoreauSenior .Net ConsultantCommented:
Something like this:

Private Sub Command1_Click()
Dim intI As Integer
Dim str1 As String
Dim str2 As String
Dim varX As Variant


    str1 = "01012000  john032 male  02012000  richard45 female  03012000  samy060  male"
    str1 = Replace(str1, "  ", " ")
    varX = Split(str1, " ")
    For intI = LBound(varX) To UBound(varX)
        If (intI Mod 3) = 0 Then
            Debug.Print str2
            str2 = ""
        End If
        str2 = str2 & varX(intI) & ";"
    Next
    Debug.Print str2
End Sub
0
 
JOHNHOAuthor Commented:
like this,

the below is the real situation. the real file is like the below

17269  2407199600000002400119623700000010000000001000 13166  2407199600000019600686253600000010000000001000 13166  2407199600000019700686253600000010000000001000 13166  2407199600000019800686253600000030000000003000 13166  2407199600000020100686253600000050000000005000 007500100000000000500000000000365738601081996        

and my code for viewing the above record is as below


Public Sub FILLFORM(STRDATA)
Text1 = Trim(Mid(STRDATA, 1, 1))
Text2 = Trim(Mid(STRDATA, 2, 6))
Text3 = Trim(Mid(STRDATA, 8, 8))
Text4 = Trim(Mid(STRDATA, 16, 9))
Text5 = Trim(Mid(STRDATA, 25, 9))
Text6 = Trim(Mid(STRDATA, 34, 10))
Text7 = Trim(Mid(STRDATA, 44, 10))
Text8 = Trim(Mid(STRDATA, 54, 54))
End Sub

Dim CommandString As String
Dim STRDATA As String
Do
Line Input #1, STRDATA
Call FILLFORM(STRDATA)
DoEvents
Debug.Print STRDATA
Loop Until EOF(1)
Call closerfile

but the results is i just can get the first record only and the following record wont be show.


help me pls.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
JOHNHOAuthor Commented:
plus

i think this is the delimited type of file.
0
 
Éric MoreauSenior .Net ConsultantCommented:
After outputting your line to the Immediate Window (with Debug.Print), what do you see? If you only see one line this is because you don't have a Carriage-Return-LineFeed character in your file.

Also, how did you code your Open statement?

0
 
JOHNHOAuthor Commented:
or u can continue my code.

how do i ask it to show the second record after the first record.

i hope u all understand it.
0
 
JOHNHOAuthor Commented:
my open statement is as below,

Open "a:\cft001.txt" For Input As #1

and in the imme win i only can see 1 line of record only.

so what to do ?
0
 
JOHNHOAuthor Commented:
plus

all the data that i just post before this is all in 1 line. i mean all the data inside 1 line and we need  to separeted it 1 by 1.  


in in immed win i can see 1 line data but it contains 2 record. but i need to separated it to become 2 record, how ?
0
 
Éric MoreauSenior .Net ConsultantCommented:
«and in the imme win i only can see 1 line of record only. »
Is this line contains all your file?

Also, with this code, you are supposed to see only the last line because you always overwrite the contents of text boxes.
0
 
Éric MoreauSenior .Net ConsultantCommented:
«in in immed win i can see 1 line data but it contains 2 record. but i need to separated it to become 2 record, how ?»
Did you create this file? Show us the code you use for this.
0
 
Brendt HessSenior DBACommented:
I think I understand what you're asking.  You have a data file 'cft001.txt' that contains a continuous stream of data.  This data has multiple records.

If all of the records in the file are the same length, then you can change your code to read the data in like this:

-------------

You would open the file like this:

Open "a:\cft001.txt" For Binary Access Read As #1

-------------------
and your routine would be modified like this:

Public Sub FILLFORM(STRDATA)
Text1 = Trim(Mid(STRDATA, 1, 1))
Text2 = Trim(Mid(STRDATA, 2, 6))
Text3 = Trim(Mid(STRDATA, 8, 8))
Text4 = Trim(Mid(STRDATA, 16, 9))
Text5 = Trim(Mid(STRDATA, 25, 9))
Text6 = Trim(Mid(STRDATA, 34, 10))
Text7 = Trim(Mid(STRDATA, 44, 10))
Text8 = Trim(Mid(STRDATA, 54, 54))
End Sub

Dim CommandString As String
Dim STRDATA As String
Const RecordLength=108 ' using above
                       'breakout as
                       'actual record
                       'length

STRDATA = Input(RecordLength, #1)

Do While Not EOF(1)
  Call FILLFORM(STRDATA)
  DoEvents
  Debug.Print STRDATA
  STRDATA = Input(RecordLength, #1)
Loop
Call closerfile
0
 
JOHNHOAuthor Commented:
fail ,

to bhess1.

it show me that "bad file name or number".

for your information, the record lenght for 1 record is 54 character. the second record will be the next number.

so how do i do it ?

for more clear here is the data that contains 2 record in 1 line. so pls do it for me.



18842  2802200000000168700130283500000010000000001000 14545W 2802200000000076600525030300000010000000000400 007500100000000000200000000000055454003032000        


0
 
JOHNHOAuthor Commented:
fail ,

to bhess1.

it show me that "bad file name or number".

for your information, the record lenght for 1 record is 54 character. the second record will be the next number.

so how do i do it ?

for more clear here is the data that contains 2 record in 1 line. so pls do it for me.



18842  2802200000000168700130283500000010000000001000 14545W 2802200000000076600525030300000010000000000400 007500100000000000200000000000055454003032000        


0
 
JOHNHOAuthor Commented:
YES I CAN DO IT !!!




SORRY BHESS1.
THANKS FOR HELPING ME.

0
 
Brendt HessSenior DBACommented:
No problem - glad to help
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 8
  • 4
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now