?
Solved

extract values from file

Posted on 2003-03-17
5
Medium Priority
?
146 Views
Last Modified: 2010-05-03
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
Comment
Question by:philanthropvrce
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 3

Accepted Solution

by:
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
    'Place your code here
   End If
  Wend
 Close FileNumber
0
 

Author Comment

by:philanthropvrce
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

by:aelatik
ID: 8157444
Private Sub Form_Load()
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
 
 'Added to Docm's code  
  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

by:CleanupPing
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

by:GPrentice00
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

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

GPrentice00
EE Cleanup Volunteer
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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 Month10 days, 18 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question