Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Problem using split function

Reply
 
Old 07-23-2008   #1 (permalink)
Meat


 
 

Problem using split function

Hi,

When I use the split function to get data from a txt file, it always skip
lines that begins with text in the second part. Lines in the txt file looks
like this :

Server1;tata,123,always;PROD
Server2;456,never;PROD
Server3;tata,789,always;TEST

Here is the code I use to get the data :

set objFile = CreateObject("Scripting.FileSystemObject")
set TheFile = objFile.GetFile(srcFile)
set objServer = objFile.OpenTextFile(TheFile, ForReading, true)

strSearching = objServer.ReadLine
VarArray = Split(strSearching, ";", -1, 1)

I don't know why but it always skip the lines that the second part of the
split begins with "tata".

Thank you.



My System SpecsSystem Spec
Old 07-23-2008   #2 (permalink)
mayayana


 
 

Re: Problem using split function

Your code sample seems to be incomplete.
You only show reading one line. Since the Split
function does not block the word "tata", the
problem must be in a part of the code that you
didn't post.
Quote:

> When I use the split function to get data from a txt file, it always skip
> lines that begins with text in the second part. Lines in the txt file
looks
Quote:

> like this :
>
> Server1;tata,123,always;PROD
> Server2;456,never;PROD
> Server3;tata,789,always;TEST
>
> Here is the code I use to get the data :
Quote:

> set objFile = CreateObject("Scripting.FileSystemObject")
> set TheFile = objFile.GetFile(srcFile)
> set objServer = objFile.OpenTextFile(TheFile, ForReading, true)
>
> strSearching = objServer.ReadLine
> VarArray = Split(strSearching, ";", -1, 1)
>
> I don't know why but it always skip the lines that the second part of the
> split begins with "tata".
>
> Thank you.
>
>

My System SpecsSystem Spec
Old 07-23-2008   #3 (permalink)
Pegasus \(MVP\)


 
 

Re: Problem using split function


"Meat" <Meat@xxxxxx> wrote in message
news:CAD384B3-4413-41CA-A8E4-788E0AC66D37@xxxxxx
Quote:

> Hi,
>
> When I use the split function to get data from a txt file, it always skip
> lines that begins with text in the second part. Lines in the txt file
> looks
> like this :
>
> Server1;tata,123,always;PROD
> Server2;456,never;PROD
> Server3;tata,789,always;TEST
>
> Here is the code I use to get the data :
>
> set objFile = CreateObject("Scripting.FileSystemObject")
> set TheFile = objFile.GetFile(srcFile)
> set objServer = objFile.OpenTextFile(TheFile, ForReading, true)
>
> strSearching = objServer.ReadLine
> VarArray = Split(strSearching, ";", -1, 1)
>
> I don't know why but it always skip the lines that the second part of the
> split begins with "tata".
>
> Thank you.
I can't see anything wrong with your code - perhaps you did not
post the exact code that causes you a problem. Using your data
lines, I ran this slightly modified version without any problems:

srcfile="d:\temp\test.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objServer = objFSO.OpenTextFile(srcFile, 1, True)

While Not objServer.AtEndOfStream
strSearching = objServer.ReadLine
WScript.echo "Source=" & strSearching
VarArray = Split(strSearching, ";")
strLine = ""
For i = 0 To UBound(VarArray)
strLine = strLine & VarArray(i) & "/"
Next
WScript.echo "Target=" & strLine
Wend


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
VBscript Array Split Function VB Script
Keyboard second function problem Vista hardware & devices
Split function PowerShell
Vista Update Causing Split-Screen Problem Vista hardware & devices
Perl split function equivalent PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46