473,395 Members | 1,905 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to extract data from a text file using VB6?

The content of the text file look something like this :

CONTINUATION TEXT 0002

PATIS/00977PATISC/NEPCBK1V71310583/013 10-06-01 10:32:46
7724 NetM NETMPATN 2937/08564

REGISTRATION POINT: BHK1424 ORIGIN OBJECT:
RGPT TYPE: DOUBLE DESTINATION OBJECT:

TRA TIM CALL NUMBER DURATION NUMBER OF A-SIDE B-SIDE
GRP GRP DURATION OF CALLS BEF.ANSWER SEIZURES CHARGES CHARGES
---+---+----------+---------+----------+----------+----------+----------
1 1 123 856 0 0 0 0
INTERRUPTION TEXT JOB 7724



>>>>>> I want to extract Registration point: value(single string) and the number values below in the same line in text and/or excel sheet as below for the whole file.

BHK1424 1 1 123 856 0 0 0 0

I would be very grateful if some VB expert would lend me some advice.


Thanks !!
Sandesh
Jan 21 '11 #1
2 2011
Here's somethingyou can use

Expand|Select|Wrap|Line Numbers
  1. Const ForReading = 1, ForWriting = 2, ForAppending = 8
  2. Dim fs, f as object
  3.  
  4. Public Sub getInfo()
  5. Dim firstVal, finalVal, strContents As String
  6.  
  7. Set fs = CreateObject("Scripting.FileSystemObject")
  8. Set f = fs.OpenTextFile("fullpath", ForReading) 'put full path of text file in place of FullPath
  9.  
  10. Do Until InStr(1, strContents, "REGISTRATION POINT") = 1
  11.     strContents = f.readline
  12. Loop
  13. firstVal = Mid(strContents, 21, 7)
  14. Do
  15.     strContents = f.readline
  16. Loop Until InStr(1, strContents, "+") >= 1  'this is assuming that the numbers allways follow the line with the + signs
  17. strContents = f.readline
  18. finalVal = firstVal + " " + strContents
  19. End Sub
  20.  
Jan 21 '11 #2
Sorry i forgot to add this to the end of the vbcode,

Expand|Select|Wrap|Line Numbers
  1. f.close
  2. set f = nothing
  3. set fs = nothing
  4.  
Jan 21 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Simon Verona | last post by:
Not sure if this is the best group... it may be better off in one of the ADO groups, but I'm sure somebody here knows the answer: I'm trying to load up a text file using ADO.net, as follows: ...
2
by: Praveen_db2 | last post by:
Hi all Db2 8.1.3 windows Is there any way to write data into a text file using a stored procedure? The way we return a cursor output to the calling application, can we return data in a text...
1
by: christine0207 | last post by:
Hi, how to generate a fixed length data text file using Scripting.TextStream / filesystemobject.
2
by: asenthil | last post by:
Hai, i'm a beginner to java... just now i had tried to read and write files using java... and then i had tried to connect a database using jdbc... now i want to export the data's from a...
4
by: varsha desai | last post by:
Hello there, I want to change some data(which is in one line only) of text file using VB 6.0. Which is the best method for it? Another question is I want to delete last two, three lines...
1
by: neveen | last post by:
i want to open and read text file using j2me that can run on mobile 6630 then i want to make button called read that when pressed the data inside text display
2
by: sajidali | last post by:
i am trying to append a text file using c#. when i executes my application i writes to the text file using more then one functions. i want to append file only during execution of programe. next time...
3
by: tivicoo | last post by:
I have a 16 bit array called ADData, and i want to save this array to a text file using C#. i tried to use different codes that i located online but when i open the saved data on notepad the data...
1
by: MiziaQ | last post by:
How can I delete a row of data from a data/text file in vb6 ? I am using an MSFlexGrid, so the user can select which row is to be deleted. Thanks in advance, MiziaQ
0
by: Thiem Teddy | last post by:
Dear all I use VB6 to export data into xls or text file, I followed this example ( http://bytes.com/topic/visual-basic/answers/530866-how-export-table-data-into-xls-text-file-using-vb6 ). but I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.