Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 24th, 2003, 03:06 AM
papamavs papamavs is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 3 papamavs User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Split function Errors in VB Script

Hi,
I am trying to use Split function in VBScript and the code errors out on me with a Error 800A0009 error. Here is what I am trying to do..

I have a .txt file that I am opening (using FSO) and reading each line. If the line starts with the word TOTAL, then, I am reading that line and using split function to get the data. Here is the code:

Do While Not FSOStream.AtEndOfStream
CID = ""
CName = ""
CSSchMin = ""
CSMinInAdhere = ""
CSMinOutAdhere = ""

CurrentLine = FSOStream.ReadLine

'***********GetCustomer ID and Name
If IsCustNameRec(CurrentLine) Then
Dim CID, CName
CID = Split(CurrentLine, " ")
CName = Split(CurrentLine, " - ")
CSID = (Trim(CID(0)))
CSName = CStr(Trim(Mid(CName(0), Len(CID(0)) + 1)))
End If

'Start ur loop again to go to the Customer Total line
'***********Get Customer Totals
If IsCustTotalRec(CurrentLine) Then
Dim CurStr
Dim StrLine, strSchMin
Dim CTotal1, CTotal2, CTotal3, CTotal4

StrLine = CurrentLine

'***Get Scheduled time
CurStr = Split(StrLine, "Total ")
StrLine = CurStr(1)
CTotal1 = Split(Trim(StrLine))
CSSchMin = CTotal1(0)
CSSchMin = GetMinutes(CSSchMin) 'Converting Hrs into Minutes


If CSSchMin = 0 then
CSSchMin = 0
CSMinInAdhere = 0
CSMinOutAdhere = 0
Else
'***Get Actual time
CurStr = ""
CurStr = Split(StrLine, CTotal1(0))
StrLine = CurStr(1)
CTotal2 = Split(Trim(StrLine))

'***Get Minutes In Adherence
CurStr = ""
CurStr = Split(StrLine, CTotal2(0))
StrLine = CurStr(1)
CTotal3 = Split(Trim(StrLine))
CSMinInAdhere = CTotal3(0)

'***Get Minutes Out of Adherence
CurStr = ""
CurStr = Split(StrLine, CTotal3(0))
StrLine = CurStr(1)
CTotal4 = Split(Trim(StrLine))
CSMinOutAdhere=CTotal4(0)
End If

RecordCounter = RecordCounter + 1
End If
Loop

'************ FUNCTIONS **********************

Function IsCustNameRec(CurrentLine)
RegVal = TestRegExp(CurrentLine, "\d{2,4}\s([A-Z])")
If RegVal <> "" Then
IsCustNameRec = True
Else
IsCustNameRec = False
End If
End Function

'************************************************
Function IsCustTotalRec(CurrentLine)
If UCase(Left(CurrentLine, 5)) = "TOTAL" Then
IsCustTotalRec = True
Else
IsCustTotalRec = False
End If
End Function

'************************************************
Function GetMinutes(TotHrs)
Dim OnlyHrs
OnlyHrs = Split(TotHrs, ":")
GetMinutes = (("0" & OnlyHrs(0)) * 60) + ("0" & OnlyHrs(1))
End Function



The data looks like this:
1680 Butt,Karla - Adherence Summary

-------- Adherence -------- ------------------ Conformance ------------------
Scheduled Scheduled Actual Min. In Min.Out Perc. In +/- Min. Perc. In Percent of Percent of
Activities Time Time Adhere Adhere Adhere Conform Conform Total Sched. Total Actual
-------------------- --------- --------- ------- ------- ------ ------- -------- ------------ ------------
Logged In 143:01 76:31 4415 4166 51 % -3990 54 % 70 % 37 %
Logged Out 60:59 128:41 3507 176 96 % +4062 211 % 30 % 63 %
==================== ========= ========= ======= ======= ====== =======
Total 204:00 205:12 7922 4342 65 % +72




286 Carter, Maggie - Adherence Summary

-------- Adherence -------- ------------------ Conformance ------------------
Scheduled Scheduled Actual Min. In Min.Out Perc. In +/- Min. Perc. In Percent of Percent of
Activities Time Time Adhere Adhere Adhere Conform Conform Total Sched. Total Actual
-------------------- --------- --------- ------- ------- ------ ------- -------- ------------ ------------
==================== ========= ========= ======= ======= ====== =======
Total 0:00 0:00 0 0 0 % +0

I am getting an error message whenever I encounter a 0:00 value in the data even though I am checking for the 0:00. Is there any other way I can check this? Thanks in advacen for all the help.
P

Reply With Quote
  #2  
Old November 25th, 2003, 08:48 PM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
I give you a advice:u can decrease your code to test your each function set,and intergate all function set to a whole program for test..

Reply With Quote
  #3  
Old November 25th, 2003, 10:41 PM
papamavs papamavs is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 3 papamavs User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks cleverpig. I figured out what the problem was. I had to check for the Ubound of the array. It works now. Thanks and have a great holiday weekend.

Reply With Quote
  #4  
Old November 27th, 2003, 02:51 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
No thanks.Good luck to u!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Split function Errors in VB Script


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT