Go Back   Novahq.net Forum > Computers > Web design and Programming
FAQ Community Calendar Today's Posts Search

Web design and Programming Discuss website creation and other programming topics.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-06-2006, 09:16 PM
DevilDog#1 is offline DevilDog#1

Join Date: Jul 2002
Posts: 7,040

Parsing a line in Excel using VBScripting

Anyone has a good function I can use?

InStr or Midstr?
__________________








Quote:
If I don't do that doesn't mean I can't - DD#1
Reply With Quote
  #2  
Old 11-06-2006, 10:32 PM
IcIshoot is offline IcIshoot

Join Date: Mar 2004
Location: Farmington Hills, MI
Posts: 1,473

Send a message via AIM to IcIshoot Send a message via MSN to IcIshoot Send a message via Yahoo to IcIshoot
what are you trying to accomplish? (split a string, pull data from it, etc)

from what I remember, instr basicaly checks that a substring is in the string

mid() will pull letters from the given string, starting where you tell it to and the length to pull out.
IcI
Reply With Quote
  #3  
Old 11-07-2006, 06:48 PM
DevilDog#1 is offline DevilDog#1

Join Date: Jul 2002
Posts: 7,040

Yep. Pulling data from row # 5 of an Excel File.

Looking for 9 digit and 5 digits on the row.
__________________








Quote:
If I don't do that doesn't mean I can't - DD#1
Reply With Quote
  #4  
Old 11-07-2006, 07:36 PM
IcIshoot is offline IcIshoot

Join Date: Mar 2004
Location: Farmington Hills, MI
Posts: 1,473

Send a message via AIM to IcIshoot Send a message via MSN to IcIshoot Send a message via Yahoo to IcIshoot
can you give a example of what the line looks like? as is the line consistently the same?

An other thought, are you pulling this data from an excel sheet that is open up and are the numbers your trying to get in their own cells?


IcI
Reply With Quote
  #5  
Old 11-07-2006, 07:58 PM
DevilDog#1 is offline DevilDog#1

Join Date: Jul 2002
Posts: 7,040

Yep

ADJASDHj: 123456789 00000000 ASDSDHS: 1234567

They are on row 5 column A
__________________








Quote:
If I don't do that doesn't mean I can't - DD#1
Reply With Quote
  #6  
Old 11-07-2006, 08:55 PM
IcIshoot is offline IcIshoot

Join Date: Mar 2004
Location: Farmington Hills, MI
Posts: 1,473

Send a message via AIM to IcIshoot Send a message via MSN to IcIshoot Send a message via Yahoo to IcIshoot
I had an reply all typed up, went to submit it, submission failed


Ok, I did what it looks like your trying to do:

But this method will only work if the length of each field stays the same if you have multiple rows like your sample (ie, all the letter and number groupings stay the same length, only the data changes)


using cell A12 for my source, and copying your sample

I put the first group of numbers you have bolded into cell A15 by entering "=MID(A12,10,10)" into cell A15.


Put the second group of bold numbers into cell A17 by entering "=MID(A12,38,8)" into said cell.

(both examples with out the " marks.


IcI
Reply With Quote
  #7  
Old 11-14-2006, 06:15 PM
DevilDog#1 is offline DevilDog#1

Join Date: Jul 2002
Posts: 7,040

Quote:
Originally posted by icishoot
I had an reply all typed up, went to submit it, submission failed


Ok, I did what it looks like your trying to do:

But this method will only work if the length of each field stays the same if you have multiple rows like your sample (ie, all the letter and number groupings stay the same length, only the data changes)


using cell A12 for my source, and copying your sample

I put the first group of numbers you have bolded into cell A15 by entering "=MID(A12,10,10)" into cell A15.


Put the second group of bold numbers into cell A17 by entering "=MID(A12,38,8)" into said cell.

(both examples with out the " marks.


IcI

Thanks ICI ...

Below is the code I came up with and works like a charm.

PHP Code:
Const ForReading ,ForWriting 2
Const File_Path "C:\"
Const File_Write_Path ="
C:\"
Const Read_File_Name = "
xyz.txt"
Const Write_File_Name ="
abc.txt"


Dim objFSORead, objFSOWrite, objFileRead, objFileWrite, strTextRead, strTextWrite, strRxNum, strOrdNum

Set objFSORead = CreateObject("
Scripting.FileSystemObject")
Set objFSOWrite = CreateObject("
Scripting.FileSystemObject") 

Set objFileRead = objFSORead.OpenTextFile(File_Path & Read_File_Name, ForReading)
Set objFileWrite = objFSOWrite.CreateTextFile(File_Write_Path & Write_File_Name, ForWriting) 

Do Until objFileRead.AtEndOfStream

        strTextRead = objFileRead.ReadLine

'Check inputfile  which contains the X and Y
         If condition statement Then

            strTextWrite = strTextRead 
            objFileWrite.WriteLine strTextWrite  
           

            strRxNum = Mid(strTextWrite, 22, 9)   
            strOrdNum = Mid(strTextWrite, 66, 7)


       End If

Loop


objFileRead.Close
objFileWrite.Close   

Set objFileRead = Nothing
Set objFSORead = Nothing
Set objFileWrite = Nothing   
Set objFSOWrite = Nothing 
Need some Error handling but other than that it should be good.
__________________








Quote:
If I don't do that doesn't mean I can't - DD#1
Reply With Quote
  #8  
Old 11-14-2006, 08:59 PM
Scott is offline Scott
Scott's Avatar
AKA. Panther

Join Date: Sep 2001
Location: Minneapolis, MN
Posts: 10,922

gj dd
__________________

04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Why do I got that line on my SIG dave61 General Chat 8 08-11-2009 02:47 PM
things not to do on-line Hellfighter General Chat 14 03-29-2007 09:27 PM
New movie line up. JakeTKD General Chat 16 01-22-2006 01:26 PM
The Best comeback line ever:)!!!! BADDOG Humor & Jokes 11 12-09-2005 10:46 AM
Playing On-Line rich887210 Delta Force 0 02-16-2003 03:08 PM


All times are GMT -5. The time now is 06:03 PM.




Powered by vBulletin®