|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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..
|
|
#3
|
|||
|
|||
|
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.
|
|
#4
|
|||
|
|||
|
No thanks.Good luck to u!
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Split function Errors in VB Script |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|