Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
Solved

# extract values from file

Posted on 2003-03-17
Medium Priority
147 Views
I have a file from which values corresponding to A line has to be read. Reading the line:
CompositeCO    :  12  12 45 125 78.23 78 98 545 45
The above line is repeated many times in the file and the values may vary for each line of CompositeCO repeated. The unique variable I have used is ---getthis = "     Composite CO  :" then using the instr fun and split I'm extracting.
The only problem facing is reading the next lines corresponding to CompositeCO from which values have to be extracted.

thanks in advance. I will post if i get the solution.
Sheetal
0
Question by:philanthropvrce

LVL 3

Accepted Solution

DocM earned 1000 total points
ID: 8156765

FileNumber = FreeFile
Open "myfilename" For Input As FileNumber
While Not EOF(FileNumber)
Line Input #FileNumber, a
'Check if CompositeCo is in this line
If InStr(UCase(a), UCase("CompositeCO")) > 0 Then
End If
Wend
Close FileNumber
0

Author Comment

ID: 8157107
imagine the file:

Composite CO : 12 48 478 898 9 8 6 9 78
again after few lines
Composite CO : 11 25 6 5 78 9 8 100 5.236
again after few lines
Composite CO : 45 78 9 5.545 65.523
etc....
I want the last values like 78, 5.236,65.523

When i use the
if ...then will I not everytime get stuck with the first occurence of Composite CO : and never go ahead and extract other values corresponding to other lines.

so I will have to overcome the
Line Input #fnum
How do I go for the next line where Composite CO is occuring.

Sheetal

0

LVL 14

Expert Comment

ID: 8157444
FileNumber = FreeFile
Open "c:\test.txt" For Input As FileNumber

While Not EOF(FileNumber)
Line Input #FileNumber, a
If InStr(UCase(a), UCase("Composite CO")) > 0 Then

Dim MyPos As Long
Dim MyValue As Long
MyPos = InStr(1, StrReverse(a), " ")
MsgBox Right(a, MyPos - 1)

End If
Wend
Close FileNumber
End Sub
0

Expert Comment

ID: 8532133
Hi philanthropvrce,
This old question (QID 20554259) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
0

LVL 6

Expert Comment

ID: 8957137
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

-->Split between DocM and aelatik

GPrentice00
EE Cleanup Volunteer
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
###### Suggested Courses
Course of the Month12 days, 1 hour left to enroll