Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual 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 ASP Free Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old July 27th, 2004, 08:54 PM
mysticssjgoku4 mysticssjgoku4 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 1 mysticssjgoku4 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
VB script BS

Here i get this when i try to run the script, but what is wrong with it?

Quote:
Line:17
Char:25
Error: Expected End of Statement
Code: 800A0401
Source: Microsoft VBScript Compilation Error
here is the code

Quote:
Private Const ForReading = 1 'FileSystemObject constants
Private Const ForWriting = 2
Private Const ForAppending = 8
Public FileList As New Collection 'List of files to search
Public Results As New Collection 'Results filenames
Public pos As New Collection 'Results position in file

Public Sub AddFile(path As String, filename As String)
'Add files to list. wildcards allowed
Dim s As String
s = Dir(path + filename)
Do While s <> ""
FileList.Add path + s, path + s
s = Dir
Loop
End Sub

Public Sub ClearFileList()
'Clear the files list
Dim i As Integer
For i = 1 To FileList.Count
FileList.Remove 1
Next i
End Sub

Public Function Find(st As String) As Integer
'Find st in the files listed. returns the number of results
Dim tx As String, i As Integer
Find = 0
Set fso = CreateObject("Scripting.FileSystemObject")
For i = 1 To Results.Count
Results.Remove 1
Next i
For Each fn In FileList
Set fil = fso.GetFile(fn)
Set ts = fil.OpenAsTextStream(ForReading)
tx = ts.ReadAll
i = InStr(1, tx, st)
Do While i > 0
Find = Find + 1
Results.Add fn
pos.Add i
i = InStr(i + 1, tx, st)
Loop
ts.Close
Next fn
End Function

Public Function Lines(Result As Integer, nLines As Integer) _
As String
'Returns the lines surrounding the result
'(nLines above and under)
Dim l As Integer, i As Integer
Set fso = CreateObject("Scripting.FileSystemObject")
Set fil = fso.GetFile(Results(Result))
Set ts = fil.OpenAsTextStream(ForReading)
ts.Skip (pos(Result))
l = ts.Line
If l <= nLines Then
l = nLines + 1
End If
ts.Close
Set ts = fil.OpenAsTextStream(ForReading)
For i = 1 To l - nLines - 1
ts.SkipLine
Next i
For i = 1 To nLines * 2 + 1
Lines = Lines + ts.readline + vbCrLf
Next i
ts.Close
End Function

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > VB script BS


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