Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 18th, 2006, 05:10 AM
Registered User
 
Join Date: Jan 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Get information from text file

Dear All

I have a text file named Solution.txt containing this information



   MEMBER 1. LEN - 5000. MM FY - 420. FC - 30. MPA, SIZE - 200. X 250. MMS

   LEVEL HEIGHT BAR INFO FROM TO ANCHOR
             (MM) (MM) (MM) STA END
   __________________________________________________ ___________________


     1 64. 2 - 16MM 0. 4813. YES NO
   |----------------------------------------------------------------|
   | CRITICAL POS MOMENT= 14.00 KN-MET AT 2500.MM, LOAD 101|
   | REQD STEEL= 209.MM2, ROW=0.0056, ROWMX=0.0223 ROWMN=0.0033 |
   | MAX/MIN/ACTUAL BAR SPACING= 72./ 41./ 72. MMS |
   | BASIC/REQD. DEVELOPMENT LENGTH = 292./ 230. MMS |
   |----------------------------------------------------------------|


How can I pick information in red colour and place it in to exel file name Myinfo.xls
Each number in one cell of exel program

Thank so much
 
Old January 27th, 2006, 02:24 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

You will need to “teach” your routine to “read.” My preferred way to open a text file is to add Windows Scripting Runtime as a reference in the project’s references, and use the FileSystemObject. (See help on that, and opening a TextStream for reading.)

Determine the steps necessary to find the data that you are after, and codify that.
For instance, it looks like in your case it would be something like:

 > Read first line of file into string variable
 > Find 1st space. (Could be throw away 1st 10 characters.)
 > Grab all non-whitespace up to—but not including—the next Chr(46)
 > Find InStr( "SIZE" )
 > Move right 4 characters
 > Get all up to—but not including—the next Chr(46)

And so on.
If there are not specific formats that the text file will conform to, you might not be able to do this.
 
Old February 5th, 2006, 09:53 PM
Registered User
 
Join Date: Jan 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi BrianWren

Your idea is very useful. I've it in many cases
My text file is very long and it is repeating that information but the red-numbers change value. Could you post the complete VBA code to sole that.

Thanks for your help

N.C.Hoang






Similar Threads
Thread Thread Starter Forum Replies Last Post
Append Information to a XML file YoungLuke C# 2 July 26th, 2007 02:15 PM
Choose information from text file Hoang2005 Excel VBA 0 January 18th, 2006 05:52 AM
Multiple workgroup information file dilemna Bob Bedell Access 4 January 7th, 2006 03:53 AM
File Information AndyHunt Excel VBA 3 December 9th, 2005 07:39 AM
ClassView information file Gert Visual C++ 2 August 4th, 2004 05:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.