I have a VB6 program that runs as an app, that I want to both convert it
to vb.net, and run it as a service on the server.
I have been able to create the service, and what I did was to open the
vb6 document and convert it into a vb.net program. Once I did that, the
routine "check_for_file " I yanked out & put into my service program.
The program though - doesn't work like the existing VB6 one does.
I've debugged the service as it runs, and it appears to read in the HTML
file, but dies on this line:
anchor(AnchSeq) = "<A HREF=" & Chr(34) & "#" & Mid(x, 10, 6) & Chr(34) &
">" & Mid(x, 12, 2) & "/" & Mid(x, 14, 2) & "/" & Mid(x, 10, 2) & "</A> "
that is located in the GOTMONTH: section of the code.
What happens is that it will attempt to write the file (when I open it I
get a sharing violation message), but it has only 1 byte in the file.
It must run again to put 06031201 into that file, but that's all that it
ever writes. Debugging the process, it'll step through and appear to
read everything like it should, but when it's into that section, it just
dies. No error message or anything in the logfile that gives me any
meaningful info.
Code follows.
Any help appreciated....
BC
Private Sub check_for_file( )
Dim j As Short
Dim RepDate As String
Dim RepTitle As String
Dim RunDate As String
Dim OFile As String
Dim z As String
Dim OutFile As Short
Dim AnchSeq As Short
Dim ReptMonth As String
Dim RunDay As String
Dim RunMon As String
Dim RunYear As String
Dim x As String
Dim anchor As Array
On Error GoTo FileNotThere
If FileLen("c:\000 Glen\DAORDSHP") > 0 Then GoTo FoundHim
FileNotThere:
On Error GoTo 0
GoTo ExitCheck
FoundHim:
FileOpen(1, "c:\000Glen\DAO RDSHP", OpenMode.Input)
x = LineInput(1)
x = LineInput(1)
RunYear = Mid(x, 17, 2)
RunMon = Mid(x, 11, 2)
RunDay = Mid(x, 14, 2)
x = LineInput(1)
ReptMonth = Mid(x, InStr(x, "MONTH:") + 7, 9)
FileClose()
On Error GoTo CmonthNotFound
FileOpen(1, "c:\000Glen\ord shpbu\cmonth.tx t", OpenMode.Input)
x = LineInput(1)
FileClose()
GoTo GotMonth
CmonthNotFound:
On Error GoTo 0
x = "JANUARY "
GotMonth:
On Error GoTo 0
If ReptMonth = VB.Left(x, 9) Then
AnchSeq = 2
FileOpen(1, "c:\000Glen\das is.htm", OpenMode.Input)
FileOpen(2, "c:\000Glen\das is2.htm", OpenMode.Output )
Do While Not EOF(1)
x = LineInput(1)
If VB.Left(x, 8) = "<A NAME=" Then
PrintLine(2, x)
anchor(AnchSeq) = "<A HREF=" & Chr(34) & "#" &
Mid(x, 10, 6) & Chr(34) & ">" & Mid(x, 12, 2) & "/" & Mid(x, 14, 2) &
"/" & Mid(x, 10, 2) & "</A> "
AnchSeq = AnchSeq + 1
GoTo GetTheRest
End If
Loop
GetTheRest:
Do While Not EOF(1)
x = LineInput(1)
If VB.Left(x, 8) = "<A NAME=" Then
anchor(AnchSeq) = "<A HREF=" & Chr(34) & "#" &
Mid(x, 10, 6) & Chr(34) & ">" & Mid(x, 12, 2) & "/" & Mid(x, 14, 2) &
"/" & Mid(x, 10, 2) & "</A> "
AnchSeq = AnchSeq + 1
End If
PrintLine(2, x)
Loop
FileClose()
Else
FileOpen(4, "c:\000Glen\ord shpbu\cmonth.tx t", OpenMode.Output )
PrintLine(4, ReptMonth)
FileOpen(2, "c:\000Glen\das is2.htm", OpenMode.Output )
PrintLine(2, "</BODY>")
PrintLine(2, "</HTML>")
FileClose()
End If
FileOpen(3, "c:\000Glen\das is6.htm", OpenMode.Output )
PrintLine(3, "<HTML>")
PrintLine(3, " ")
PrintLine(3, "<HEAD>")
PrintLine(3, " ")
PrintLine(3, "<META NAME=" & Chr(34) & "GENERATOR" & Chr(34) &
" CONTENT=" & Chr(34) & "VB Generated HTML" & Chr(34) & ">")
PrintLine(3, "<META NAME=" & Chr(34) & "AUTHOR" & Chr(34) & "
CONTENT=" & Chr(34) & "CodeAuthor " & Chr(34) & ">")
PrintLine(3, "</HEAD>")
PrintLine(3, " ")
PrintLine(3, "<BODY>")
PrintLine(3, " ")
PrintLine(3, "<H1><CENTE R>My Main Company, Inc.</CENTER></H1>")
PrintLine(3, " ")
PrintLine(3, "<H3><CENTER>Da ily Sales Information Reports for "
& ReptMonth & " 20" & RunYear & "</CENTER></H3>")
FileOpen(1, "c:\000Glen\DAO RDSHP", OpenMode.Input)
FileOpen(4, "c:\000Glen\ord shpbu\DA" & RunYear & RunMon &
RunDay, OpenMode.Output )
OutFile = 0
Loop1:
If EOF(1) Then GoTo EndThis
z = LineInput(1)
PrintLine(4, z)
If VB.Left(z, 7) = "REPORT:" And InStr(z, "PAGE: 1") > 0 Then
If OutFile > 0 Then FileClose(2)
OutFile = OutFile + 1
OFile = RunYear & RunMon & RunDay & VB.Right("00" &
Mid(Str(OutFile ), 2), 2) & ".txt"
FileOpen(2, "c:\000Glen \" & OFile, OpenMode.Output )
PrintLine(2, z)
z = LineInput(1)
PrintLine(4, z)
RunDate = Mid(z, 11, 8)
RepTitle = Trim(Mid(z, 20, 120))
PrintLine(2, z)
z = LineInput(1)
PrintLine(4, z)
RepDate = Mid(z, InStr(z, "MONTH:") + 17, 12)
' Print #2, z$
PrintLine(3, " ")
PrintLine(3, "<P>")
If RepTitle = "TOTAL COMPANY SUMMARY REPORT" Then
anchor(1) = "Move directly to day <A HREF=" & Chr(34) &
"#" & VB.Left(OFile, 6) & Chr(34) & ">" & RunDate & "</A> "
For j = 1 To AnchSeq - 1 Step 10
Print(3, anchor(j) & anchor(j + 1) & anchor(j + 2)
& anchor(j + 3) & anchor(j + 4) & anchor(j + 5) & anchor(j + 6) &
anchor(j + 7) & anchor(j + 8) & anchor(j + 9))
Next j
PrintLine(3, " ")
PrintLine(3, "<P>")
PrintLine(3, "<A NAME=" & Chr(34) & VB.Left(OFile, 6) &
Chr(34) & "></A>")
End If
PrintLine(3, "<A HREF=" & Chr(34) &
"http://www.myserver.co m/reports/" & OFile & Chr(34) & ">" & RepTitle &
" - " & RepDate & " (" & RunDate & ")" & "</A>")
End If
If z <> "-----------------------------" And z <>
"============== =============== " Then
If VB.Left(z, 50) = New String("=", 50) Then z = New
String("=", 140)
PrintLine(2, z)
End If
GoTo Loop1
EndThis:
PrintLine(3, "<P>")
FileOpen(5, "c:\000Glen\das is2.htm", OpenMode.Input)
Do While Not EOF(5)
x = LineInput(5)
PrintLine(3, x)
Loop
FileClose()
For j = 1 To 100
anchor(j) = ""
Next j
Kill("c:\000Gle n\DAORDSHP")
Kill("c:\000Gle n\dasis.htm")
'Dim oFile As System.IO.File
'Dim oWrite As System.IO.Strea mWriter
'oWrite = oFile.CreateTex t("C:\sample.tx t")
'OpenText()
'Dim fs As New Scripting.FileS ystemObject
Dim iLine As String
Dim oLine As String
Dim fs As System.IO.File
Dim fs2 As System.IO.File
'Dim f As Scripting.File
Dim f As System.IO.Strea mReader
Dim f2 As System.IO.Strea mWriter
f = fs.OpenText("c: \000Glen\dasis6 .htm")
f2 = fs2.CreateText( "c:\000Glen\das is.htm")
While f.Peek <> -1
iLine = f.ReadLine()
f2.WriteLine(iL ine)
End While
f.Close()
f2.Close()
ExitCheck:
End Sub 5 1465
Blasting Cap wrote: I have a VB6 program that runs as an app, that I want to both convert it to vb.net, and run it as a service on the server.
I have been able to create the service, and what I did was to open the vb6 document and convert it into a vb.net program. Once I did that, the routine "check_for_file " I yanked out & put into my service program.
The program though - doesn't work like the existing VB6 one does.
I've debugged the service as it runs, and it appears to read in the HTML file, but dies on this line:
anchor(AnchSeq) = "<A HREF=" & Chr(34) & "#" & Mid(x, 10, 6) & Chr(34) & ">" & Mid(x, 12, 2) & "/" & Mid(x, 14, 2) & "/" & Mid(x, 10, 2) & "</A> "
that is located in the GOTMONTH: section of the code.
What happens is that it will attempt to write the file (when I open it I get a sharing violation message), but it has only 1 byte in the file. It must run again to put 06031201 into that file, but that's all that it ever writes. Debugging the process, it'll step through and appear to read everything like it should, but when it's into that section, it just dies. No error message or anything in the logfile that gives me any meaningful info.
Code follows.
Any help appreciated....
BC
Private Sub check_for_file( ) Dim j As Short Dim RepDate As String Dim RepTitle As String Dim RunDate As String Dim OFile As String Dim z As String Dim OutFile As Short Dim AnchSeq As Short Dim ReptMonth As String Dim RunDay As String Dim RunMon As String Dim RunYear As String Dim x As String Dim anchor As Array
On Error GoTo FileNotThere If FileLen("c:\000 Glen\DAORDSHP") > 0 Then GoTo FoundHim FileNotThere: On Error GoTo 0 GoTo ExitCheck
FoundHim:
FileOpen(1, "c:\000Glen\DAO RDSHP", OpenMode.Input) x = LineInput(1) x = LineInput(1) RunYear = Mid(x, 17, 2) RunMon = Mid(x, 11, 2) RunDay = Mid(x, 14, 2) x = LineInput(1) ReptMonth = Mid(x, InStr(x, "MONTH:") + 7, 9) FileClose() On Error GoTo CmonthNotFound FileOpen(1, "c:\000Glen\ord shpbu\cmonth.tx t", OpenMode.Input) x = LineInput(1) FileClose() GoTo GotMonth CmonthNotFound: On Error GoTo 0 x = "JANUARY " GotMonth: On Error GoTo 0 If ReptMonth = VB.Left(x, 9) Then AnchSeq = 2 FileOpen(1, "c:\000Glen\das is.htm", OpenMode.Input) FileOpen(2, "c:\000Glen\das is2.htm", OpenMode.Output ) Do While Not EOF(1) x = LineInput(1) If VB.Left(x, 8) = "<A NAME=" Then PrintLine(2, x) anchor(AnchSeq) = "<A HREF=" & Chr(34) & "#" & Mid(x, 10, 6) & Chr(34) & ">" & Mid(x, 12, 2) & "/" & Mid(x, 14, 2) & "/" & Mid(x, 10, 2) & "</A> " AnchSeq = AnchSeq + 1 GoTo GetTheRest End If Loop GetTheRest: Do While Not EOF(1) x = LineInput(1) If VB.Left(x, 8) = "<A NAME=" Then anchor(AnchSeq) = "<A HREF=" & Chr(34) & "#" & Mid(x, 10, 6) & Chr(34) & ">" & Mid(x, 12, 2) & "/" & Mid(x, 14, 2) & "/" & Mid(x, 10, 2) & "</A> " AnchSeq = AnchSeq + 1 End If PrintLine(2, x) Loop FileClose() Else FileOpen(4, "c:\000Glen\ord shpbu\cmonth.tx t", OpenMode.Output ) PrintLine(4, ReptMonth) FileOpen(2, "c:\000Glen\das is2.htm", OpenMode.Output ) PrintLine(2, "</BODY>") PrintLine(2, "</HTML>") FileClose() End If
FileOpen(3, "c:\000Glen\das is6.htm", OpenMode.Output ) PrintLine(3, "<HTML>") PrintLine(3, " ") PrintLine(3, "<HEAD>") PrintLine(3, " ") PrintLine(3, "<META NAME=" & Chr(34) & "GENERATOR" & Chr(34) & " CONTENT=" & Chr(34) & "VB Generated HTML" & Chr(34) & ">") PrintLine(3, "<META NAME=" & Chr(34) & "AUTHOR" & Chr(34) & " CONTENT=" & Chr(34) & "CodeAuthor " & Chr(34) & ">") PrintLine(3, "</HEAD>") PrintLine(3, " ") PrintLine(3, "<BODY>") PrintLine(3, " ") PrintLine(3, "<H1><CENTE R>My Main Company, Inc.</CENTER></H1>") PrintLine(3, " ") PrintLine(3, "<H3><CENTER>Da ily Sales Information Reports for " & ReptMonth & " 20" & RunYear & "</CENTER></H3>")
FileOpen(1, "c:\000Glen\DAO RDSHP", OpenMode.Input) FileOpen(4, "c:\000Glen\ord shpbu\DA" & RunYear & RunMon & RunDay, OpenMode.Output ) OutFile = 0 Loop1: If EOF(1) Then GoTo EndThis z = LineInput(1) PrintLine(4, z)
If VB.Left(z, 7) = "REPORT:" And InStr(z, "PAGE: 1") > 0 Then
If OutFile > 0 Then FileClose(2) OutFile = OutFile + 1 OFile = RunYear & RunMon & RunDay & VB.Right("00" & Mid(Str(OutFile ), 2), 2) & ".txt" FileOpen(2, "c:\000Glen \" & OFile, OpenMode.Output ) PrintLine(2, z) z = LineInput(1) PrintLine(4, z) RunDate = Mid(z, 11, 8) RepTitle = Trim(Mid(z, 20, 120)) PrintLine(2, z) z = LineInput(1) PrintLine(4, z) RepDate = Mid(z, InStr(z, "MONTH:") + 17, 12) ' Print #2, z$ PrintLine(3, " ") PrintLine(3, "<P>") If RepTitle = "TOTAL COMPANY SUMMARY REPORT" Then anchor(1) = "Move directly to day <A HREF=" & Chr(34) & "#" & VB.Left(OFile, 6) & Chr(34) & ">" & RunDate & "</A> " For j = 1 To AnchSeq - 1 Step 10 Print(3, anchor(j) & anchor(j + 1) & anchor(j + 2) & anchor(j + 3) & anchor(j + 4) & anchor(j + 5) & anchor(j + 6) & anchor(j + 7) & anchor(j + 8) & anchor(j + 9)) Next j PrintLine(3, " ") PrintLine(3, "<P>") PrintLine(3, "<A NAME=" & Chr(34) & VB.Left(OFile, 6) & Chr(34) & "></A>") End If PrintLine(3, "<A HREF=" & Chr(34) & "http://www.myserver.co m/reports/" & OFile & Chr(34) & ">" & RepTitle & " - " & RepDate & " (" & RunDate & ")" & "</A>") End If If z <> "-----------------------------" And z <> "============== =============== " Then If VB.Left(z, 50) = New String("=", 50) Then z = New String("=", 140) PrintLine(2, z) End If GoTo Loop1 EndThis: PrintLine(3, "<P>") FileOpen(5, "c:\000Glen\das is2.htm", OpenMode.Input) Do While Not EOF(5) x = LineInput(5) PrintLine(3, x) Loop FileClose() For j = 1 To 100 anchor(j) = "" Next j Kill("c:\000Gle n\DAORDSHP") Kill("c:\000Gle n\dasis.htm")
'Dim oFile As System.IO.File 'Dim oWrite As System.IO.Strea mWriter 'oWrite = oFile.CreateTex t("C:\sample.tx t") 'OpenText()
'Dim fs As New Scripting.FileS ystemObject Dim iLine As String Dim oLine As String Dim fs As System.IO.File Dim fs2 As System.IO.File 'Dim f As Scripting.File Dim f As System.IO.Strea mReader Dim f2 As System.IO.Strea mWriter f = fs.OpenText("c: \000Glen\dasis6 .htm") f2 = fs2.CreateText( "c:\000Glen\das is.htm")
While f.Peek <> -1 iLine = f.ReadLine() f2.WriteLine(iL ine) End While
f.Close() f2.Close() ExitCheck:
End Sub
Try running the program as a console or windows form application. Get
that working first then paste it into your service. This will help you
figure out if there is a problem on how you are running the service or
your function.
How is your Check_for_file function called in your service? When is it
triggered? Are you starting a new thread in the service to run the
check_for_file?
Chris
Chris wrote: Blasting Cap wrote: I have a VB6 program that runs as an app, that I want to both convert it to vb.net, and run it as a service on the server.
I have been able to create the service, and what I did was to open the vb6 document and convert it into a vb.net program. Once I did that, the routine "check_for_file " I yanked out & put into my service program.
The program though - doesn't work like the existing VB6 one does.
I've debugged the service as it runs, and it appears to read in the HTML file, but dies on this line:
anchor(AnchSeq) = "<A HREF=" & Chr(34) & "#" & Mid(x, 10, 6) & Chr(34) & ">" & Mid(x, 12, 2) & "/" & Mid(x, 14, 2) & "/" & Mid(x, 10, 2) & "</A> "
that is located in the GOTMONTH: section of the code.
What happens is that it will attempt to write the file (when I open it I get a sharing violation message), but it has only 1 byte in the file. It must run again to put 06031201 into that file, but that's all that it ever writes. Debugging the process, it'll step through and appear to read everything like it should, but when it's into that section, it just dies. No error message or anything in the logfile that gives me any meaningful info.
Code follows.
Any help appreciated....
BC
Private Sub check_for_file( ) Dim j As Short Dim RepDate As String Dim RepTitle As String Dim RunDate As String Dim OFile As String Dim z As String Dim OutFile As Short Dim AnchSeq As Short Dim ReptMonth As String Dim RunDay As String Dim RunMon As String Dim RunYear As String Dim x As String Dim anchor As Array
On Error GoTo FileNotThere If FileLen("c:\000 Glen\DAORDSHP") > 0 Then GoTo FoundHim FileNotThere: On Error GoTo 0 GoTo ExitCheck
FoundHim:
FileOpen(1, "c:\000Glen\DAO RDSHP", OpenMode.Input) x = LineInput(1) x = LineInput(1) RunYear = Mid(x, 17, 2) RunMon = Mid(x, 11, 2) RunDay = Mid(x, 14, 2) x = LineInput(1) ReptMonth = Mid(x, InStr(x, "MONTH:") + 7, 9) FileClose() On Error GoTo CmonthNotFound FileOpen(1, "c:\000Glen\ord shpbu\cmonth.tx t", OpenMode.Input) x = LineInput(1) FileClose() GoTo GotMonth CmonthNotFound: On Error GoTo 0 x = "JANUARY " GotMonth: On Error GoTo 0 If ReptMonth = VB.Left(x, 9) Then AnchSeq = 2 FileOpen(1, "c:\000Glen\das is.htm", OpenMode.Input) FileOpen(2, "c:\000Glen\das is2.htm", OpenMode.Output ) Do While Not EOF(1) x = LineInput(1) If VB.Left(x, 8) = "<A NAME=" Then PrintLine(2, x) anchor(AnchSeq) = "<A HREF=" & Chr(34) & "#" & Mid(x, 10, 6) & Chr(34) & ">" & Mid(x, 12, 2) & "/" & Mid(x, 14, 2) & "/" & Mid(x, 10, 2) & "</A> " AnchSeq = AnchSeq + 1 GoTo GetTheRest End If Loop GetTheRest: Do While Not EOF(1) x = LineInput(1) If VB.Left(x, 8) = "<A NAME=" Then anchor(AnchSeq) = "<A HREF=" & Chr(34) & "#" & Mid(x, 10, 6) & Chr(34) & ">" & Mid(x, 12, 2) & "/" & Mid(x, 14, 2) & "/" & Mid(x, 10, 2) & "</A> " AnchSeq = AnchSeq + 1 End If PrintLine(2, x) Loop FileClose() Else FileOpen(4, "c:\000Glen\ord shpbu\cmonth.tx t", OpenMode.Output ) PrintLine(4, ReptMonth) FileOpen(2, "c:\000Glen\das is2.htm", OpenMode.Output ) PrintLine(2, "</BODY>") PrintLine(2, "</HTML>") FileClose() End If
FileOpen(3, "c:\000Glen\das is6.htm", OpenMode.Output ) PrintLine(3, "<HTML>") PrintLine(3, " ") PrintLine(3, "<HEAD>") PrintLine(3, " ") PrintLine(3, "<META NAME=" & Chr(34) & "GENERATOR" & Chr(34) & " CONTENT=" & Chr(34) & "VB Generated HTML" & Chr(34) & ">") PrintLine(3, "<META NAME=" & Chr(34) & "AUTHOR" & Chr(34) & " CONTENT=" & Chr(34) & "CodeAuthor " & Chr(34) & ">") PrintLine(3, "</HEAD>") PrintLine(3, " ") PrintLine(3, "<BODY>") PrintLine(3, " ") PrintLine(3, "<H1><CENTE R>My Main Company, Inc.</CENTER></H1>") PrintLine(3, " ") PrintLine(3, "<H3><CENTER>Da ily Sales Information Reports for " & ReptMonth & " 20" & RunYear & "</CENTER></H3>")
FileOpen(1, "c:\000Glen\DAO RDSHP", OpenMode.Input) FileOpen(4, "c:\000Glen\ord shpbu\DA" & RunYear & RunMon & RunDay, OpenMode.Output ) OutFile = 0 Loop1: If EOF(1) Then GoTo EndThis z = LineInput(1) PrintLine(4, z)
If VB.Left(z, 7) = "REPORT:" And InStr(z, "PAGE: 1") > 0 Then
If OutFile > 0 Then FileClose(2) OutFile = OutFile + 1 OFile = RunYear & RunMon & RunDay & VB.Right("00" & Mid(Str(OutFile ), 2), 2) & ".txt" FileOpen(2, "c:\000Glen \" & OFile, OpenMode.Output ) PrintLine(2, z) z = LineInput(1) PrintLine(4, z) RunDate = Mid(z, 11, 8) RepTitle = Trim(Mid(z, 20, 120)) PrintLine(2, z) z = LineInput(1) PrintLine(4, z) RepDate = Mid(z, InStr(z, "MONTH:") + 17, 12) ' Print #2, z$ PrintLine(3, " ") PrintLine(3, "<P>") If RepTitle = "TOTAL COMPANY SUMMARY REPORT" Then anchor(1) = "Move directly to day <A HREF=" & Chr(34) & "#" & VB.Left(OFile, 6) & Chr(34) & ">" & RunDate & "</A> " For j = 1 To AnchSeq - 1 Step 10 Print(3, anchor(j) & anchor(j + 1) & anchor(j + 2) & anchor(j + 3) & anchor(j + 4) & anchor(j + 5) & anchor(j + 6) & anchor(j + 7) & anchor(j + 8) & anchor(j + 9)) Next j PrintLine(3, " ") PrintLine(3, "<P>") PrintLine(3, "<A NAME=" & Chr(34) & VB.Left(OFile, 6) & Chr(34) & "></A>") End If PrintLine(3, "<A HREF=" & Chr(34) & "http://www.myserver.co m/reports/" & OFile & Chr(34) & ">" & RepTitle & " - " & RepDate & " (" & RunDate & ")" & "</A>") End If If z <> "-----------------------------" And z <> "============== =============== " Then If VB.Left(z, 50) = New String("=", 50) Then z = New String("=", 140) PrintLine(2, z) End If GoTo Loop1 EndThis: PrintLine(3, "<P>") FileOpen(5, "c:\000Glen\das is2.htm", OpenMode.Input) Do While Not EOF(5) x = LineInput(5) PrintLine(3, x) Loop FileClose() For j = 1 To 100 anchor(j) = "" Next j Kill("c:\000Gle n\DAORDSHP") Kill("c:\000Gle n\dasis.htm")
'Dim oFile As System.IO.File 'Dim oWrite As System.IO.Strea mWriter 'oWrite = oFile.CreateTex t("C:\sample.tx t") 'OpenText()
'Dim fs As New Scripting.FileS ystemObject Dim iLine As String Dim oLine As String Dim fs As System.IO.File Dim fs2 As System.IO.File 'Dim f As Scripting.File Dim f As System.IO.Strea mReader Dim f2 As System.IO.Strea mWriter f = fs.OpenText("c: \000Glen\dasis6 .htm") f2 = fs2.CreateText( "c:\000Glen\das is.htm")
While f.Peek <> -1 iLine = f.ReadLine() f2.WriteLine(iL ine) End While
f.Close() f2.Close() ExitCheck:
End Sub
Try running the program as a console or windows form application. Get that working first then paste it into your service. This will help you figure out if there is a problem on how you are running the service or your function.
How is your Check_for_file function called in your service? When is it triggered? Are you starting a new thread in the service to run the check_for_file?
Chris
Here's where I am checking:
Private Sub Timer1_Elapsed( ByVal sender As System.Object, ByVal e As
System.Timers.E lapsedEventArgs ) Handles Timer1.Elapsed
Dim MyLog As New EventLog ' create a new event log
' Check if the the Event Log Exists
If Not MyLog.SourceExi sts("mycompany Daily") Then
MyLog.CreateEve ntSource("mycom panyDaily", "mycompany
Daily") ' Create Log
End If
check_for_file( )
MyLog.Source = "mycompanyDaily "
' Write to the Log
MyLog.WriteEntr y("mycompany Daily Log", "This is log on " & _
CStr(TimeOfDay) , EventLogEntryTy pe.Information)
End Sub
The OnStart/OnStop events are:
Protected Overrides Sub OnStart(ByVal args() As String)
' Add code here to start your service. This method should
set things
' in motion so your service can do its work.
Timer1.Enabled = True
End Sub
Protected Overrides Sub OnStop()
' Add code here to perform any tear-down necessary to stop
your service.
Timer1.Enabled = False
End Sub
This stuff would work, but all I had it doing originally was to write
events at a particular interval.
The timer is set for 480000 ticks, which should be around 5-8 minutes or
so.
Re your last question - I do not know if I am or not.
I will though, take a look at running the converted app to see what's
going on.
BC
Blasting Cap wrote: Chris wrote:
Blasting Cap wrote:
I have a VB6 program that runs as an app, that I want to both convert it to vb.net, and run it as a service on the server.
I have been able to create the service, and what I did was to open the vb6 document and convert it into a vb.net program. Once I did that, the routine "check_for_file " I yanked out & put into my service program.
The program though - doesn't work like the existing VB6 one does.
I've debugged the service as it runs, and it appears to read in the HTML file, but dies on this line:
anchor(AnchSeq) = "<A HREF=" & Chr(34) & "#" & Mid(x, 10, 6) & Chr(34) & ">" & Mid(x, 12, 2) & "/" & Mid(x, 14, 2) & "/" & Mid(x, 10, 2) & "</A> "
that is located in the GOTMONTH: section of the code.
What happens is that it will attempt to write the file (when I open it I get a sharing violation message), but it has only 1 byte in the file. It must run again to put 06031201 into that file, but that's all that it ever writes. Debugging the process, it'll step through and appear to read everything like it should, but when it's into that section, it just dies. No error message or anything in the logfile that gives me any meaningful info.
Code follows.
Any help appreciated....
BC
Private Sub check_for_file( ) Dim j As Short Dim RepDate As String Dim RepTitle As String Dim RunDate As String Dim OFile As String Dim z As String Dim OutFile As Short Dim AnchSeq As Short Dim ReptMonth As String Dim RunDay As String Dim RunMon As String Dim RunYear As String Dim x As String Dim anchor As Array
On Error GoTo FileNotThere If FileLen("c:\000 Glen\DAORDSHP") > 0 Then GoTo FoundHim FileNotThere: On Error GoTo 0 GoTo ExitCheck
FoundHim:
FileOpen(1, "c:\000Glen\DAO RDSHP", OpenMode.Input) x = LineInput(1) x = LineInput(1) RunYear = Mid(x, 17, 2) RunMon = Mid(x, 11, 2) RunDay = Mid(x, 14, 2) x = LineInput(1) ReptMonth = Mid(x, InStr(x, "MONTH:") + 7, 9) FileClose() On Error GoTo CmonthNotFound FileOpen(1, "c:\000Glen\ord shpbu\cmonth.tx t", OpenMode.Input) x = LineInput(1) FileClose() GoTo GotMonth CmonthNotFound: On Error GoTo 0 x = "JANUARY " GotMonth: On Error GoTo 0 If ReptMonth = VB.Left(x, 9) Then AnchSeq = 2 FileOpen(1, "c:\000Glen\das is.htm", OpenMode.Input) FileOpen(2, "c:\000Glen\das is2.htm", OpenMode.Output ) Do While Not EOF(1) x = LineInput(1) If VB.Left(x, 8) = "<A NAME=" Then PrintLine(2, x) anchor(AnchSeq) = "<A HREF=" & Chr(34) & "#" & Mid(x, 10, 6) & Chr(34) & ">" & Mid(x, 12, 2) & "/" & Mid(x, 14, 2) & "/" & Mid(x, 10, 2) & "</A> " AnchSeq = AnchSeq + 1 GoTo GetTheRest End If Loop GetTheRest: Do While Not EOF(1) x = LineInput(1) If VB.Left(x, 8) = "<A NAME=" Then anchor(AnchSeq) = "<A HREF=" & Chr(34) & "#" & Mid(x, 10, 6) & Chr(34) & ">" & Mid(x, 12, 2) & "/" & Mid(x, 14, 2) & "/" & Mid(x, 10, 2) & "</A> " AnchSeq = AnchSeq + 1 End If PrintLine(2, x) Loop FileClose() Else FileOpen(4, "c:\000Glen\ord shpbu\cmonth.tx t", OpenMode.Output ) PrintLine(4, ReptMonth) FileOpen(2, "c:\000Glen\das is2.htm", OpenMode.Output ) PrintLine(2, "</BODY>") PrintLine(2, "</HTML>") FileClose() End If
FileOpen(3, "c:\000Glen\das is6.htm", OpenMode.Output ) PrintLine(3, "<HTML>") PrintLine(3, " ") PrintLine(3, "<HEAD>") PrintLine(3, " ") PrintLine(3, "<META NAME=" & Chr(34) & "GENERATOR" & Chr(34) & " CONTENT=" & Chr(34) & "VB Generated HTML" & Chr(34) & ">") PrintLine(3, "<META NAME=" & Chr(34) & "AUTHOR" & Chr(34) & " CONTENT=" & Chr(34) & "CodeAuthor " & Chr(34) & ">") PrintLine(3, "</HEAD>") PrintLine(3, " ") PrintLine(3, "<BODY>") PrintLine(3, " ") PrintLine(3, "<H1><CENTE R>My Main Company, Inc.</CENTER></H1>") PrintLine(3, " ") PrintLine(3, "<H3><CENTER>Da ily Sales Information Reports for " & ReptMonth & " 20" & RunYear & "</CENTER></H3>")
FileOpen(1, "c:\000Glen\DAO RDSHP", OpenMode.Input) FileOpen(4, "c:\000Glen\ord shpbu\DA" & RunYear & RunMon & RunDay, OpenMode.Output ) OutFile = 0 Loop1: If EOF(1) Then GoTo EndThis z = LineInput(1) PrintLine(4, z)
If VB.Left(z, 7) = "REPORT:" And InStr(z, "PAGE: 1") > 0 Then
If OutFile > 0 Then FileClose(2) OutFile = OutFile + 1 OFile = RunYear & RunMon & RunDay & VB.Right("00" & Mid(Str(OutFile ), 2), 2) & ".txt" FileOpen(2, "c:\000Glen \" & OFile, OpenMode.Output ) PrintLine(2, z) z = LineInput(1) PrintLine(4, z) RunDate = Mid(z, 11, 8) RepTitle = Trim(Mid(z, 20, 120)) PrintLine(2, z) z = LineInput(1) PrintLine(4, z) RepDate = Mid(z, InStr(z, "MONTH:") + 17, 12) ' Print #2, z$ PrintLine(3, " ") PrintLine(3, "<P>") If RepTitle = "TOTAL COMPANY SUMMARY REPORT" Then anchor(1) = "Move directly to day <A HREF=" & Chr(34) & "#" & VB.Left(OFile, 6) & Chr(34) & ">" & RunDate & "</A> " For j = 1 To AnchSeq - 1 Step 10 Print(3, anchor(j) & anchor(j + 1) & anchor(j + 2) & anchor(j + 3) & anchor(j + 4) & anchor(j + 5) & anchor(j + 6) & anchor(j + 7) & anchor(j + 8) & anchor(j + 9)) Next j PrintLine(3, " ") PrintLine(3, "<P>") PrintLine(3, "<A NAME=" & Chr(34) & VB.Left(OFile, 6) & Chr(34) & "></A>") End If PrintLine(3, "<A HREF=" & Chr(34) & "http://www.myserver.co m/reports/" & OFile & Chr(34) & ">" & RepTitle & " - " & RepDate & " (" & RunDate & ")" & "</A>") End If If z <> "-----------------------------" And z <> "============== =============== " Then If VB.Left(z, 50) = New String("=", 50) Then z = New String("=", 140) PrintLine(2, z) End If GoTo Loop1 EndThis: PrintLine(3, "<P>") FileOpen(5, "c:\000Glen\das is2.htm", OpenMode.Input) Do While Not EOF(5) x = LineInput(5) PrintLine(3, x) Loop FileClose() For j = 1 To 100 anchor(j) = "" Next j Kill("c:\000Gle n\DAORDSHP") Kill("c:\000Gle n\dasis.htm")
'Dim oFile As System.IO.File 'Dim oWrite As System.IO.Strea mWriter 'oWrite = oFile.CreateTex t("C:\sample.tx t") 'OpenText()
'Dim fs As New Scripting.FileS ystemObject Dim iLine As String Dim oLine As String Dim fs As System.IO.File Dim fs2 As System.IO.File 'Dim f As Scripting.File Dim f As System.IO.Strea mReader Dim f2 As System.IO.Strea mWriter f = fs.OpenText("c: \000Glen\dasis6 .htm") f2 = fs2.CreateText( "c:\000Glen\das is.htm")
While f.Peek <> -1 iLine = f.ReadLine() f2.WriteLine(iL ine) End While
f.Close() f2.Close() ExitCheck:
End Sub
Try running the program as a console or windows form application. Get that working first then paste it into your service. This will help you figure out if there is a problem on how you are running the service or your function.
How is your Check_for_file function called in your service? When is it triggered? Are you starting a new thread in the service to run the check_for_file?
Chris Here's where I am checking:
Private Sub Timer1_Elapsed( ByVal sender As System.Object, ByVal e As System.Timers.E lapsedEventArgs ) Handles Timer1.Elapsed Dim MyLog As New EventLog ' create a new event log ' Check if the the Event Log Exists If Not MyLog.SourceExi sts("mycompany Daily") Then MyLog.CreateEve ntSource("mycom panyDaily", "mycompany Daily") ' Create Log End If
check_for_file( )
MyLog.Source = "mycompanyDaily " ' Write to the Log MyLog.WriteEntr y("mycompany Daily Log", "This is log on " & _ CStr(TimeOfDay) , EventLogEntryTy pe.Information)
End Sub
The OnStart/OnStop events are:
Protected Overrides Sub OnStart(ByVal args() As String) ' Add code here to start your service. This method should set things ' in motion so your service can do its work. Timer1.Enabled = True End Sub Protected Overrides Sub OnStop() ' Add code here to perform any tear-down necessary to stop your service. Timer1.Enabled = False End Sub This stuff would work, but all I had it doing originally was to write events at a particular interval.
The timer is set for 480000 ticks, which should be around 5-8 minutes or so.
Re your last question - I do not know if I am or not.
I will though, take a look at running the converted app to see what's going on.
BC
As a general rule you should not do procssing inside the service thread,
which is what you are doing. I have always read that you should start a
new thread inside your timer_elapsed event and have the worker thread do
the work.
Someone smarter than me might want to comment on this issue.
Chris
The code in the app keeps blowing on the same line:
anchor(AnchSeq) = "<A HREF=" & Chr(34) & "#" & Mid(x, 10, 6) & Chr(34) &
">" & Mid(x, 12, 2) & "/" & Mid(x, 14, 2) & "/" & Mid(x, 10, 2) & "</A> "
It says that anchor(anchseq) is null.
It's not defined in the converted app, but I defined it as an array and
an arraylist by me outside of that, but it gives the same message each
time.
Any ideas?
BC
Chris wrote: Blasting Cap wrote: Chris wrote:
Blasting Cap wrote:
I have a VB6 program that runs as an app, that I want to both convert it to vb.net, and run it as a service on the server.
I have been able to create the service, and what I did was to open the vb6 document and convert it into a vb.net program. Once I did that, the routine "check_for_file " I yanked out & put into my service program.
The program though - doesn't work like the existing VB6 one does.
I've debugged the service as it runs, and it appears to read in the HTML file, but dies on this line:
anchor(AnchSeq) = "<A HREF=" & Chr(34) & "#" & Mid(x, 10, 6) & Chr(34) & ">" & Mid(x, 12, 2) & "/" & Mid(x, 14, 2) & "/" & Mid(x, 10, 2) & "</A> "
that is located in the GOTMONTH: section of the code.
What happens is that it will attempt to write the file (when I open it I get a sharing violation message), but it has only 1 byte in the file. It must run again to put 06031201 into that file, but that's all that it ever writes. Debugging the process, it'll step through and appear to read everything like it should, but when it's into that section, it just dies. No error message or anything in the logfile that gives me any meaningful info.
Code follows.
Any help appreciated....
BC
Private Sub check_for_file( ) Dim j As Short Dim RepDate As String Dim RepTitle As String Dim RunDate As String Dim OFile As String Dim z As String Dim OutFile As Short Dim AnchSeq As Short Dim ReptMonth As String Dim RunDay As String Dim RunMon As String Dim RunYear As String Dim x As String Dim anchor As Array
On Error GoTo FileNotThere If FileLen("c:\000 Glen\DAORDSHP") > 0 Then GoTo FoundHim FileNotThere: On Error GoTo 0 GoTo ExitCheck
FoundHim:
FileOpen(1, "c:\000Glen\DAO RDSHP", OpenMode.Input) x = LineInput(1) x = LineInput(1) RunYear = Mid(x, 17, 2) RunMon = Mid(x, 11, 2) RunDay = Mid(x, 14, 2) x = LineInput(1) ReptMonth = Mid(x, InStr(x, "MONTH:") + 7, 9) FileClose() On Error GoTo CmonthNotFound FileOpen(1, "c:\000Glen\ord shpbu\cmonth.tx t", OpenMode.Input) x = LineInput(1) FileClose() GoTo GotMonth CmonthNotFound: On Error GoTo 0 x = "JANUARY " GotMonth: On Error GoTo 0 If ReptMonth = VB.Left(x, 9) Then AnchSeq = 2 FileOpen(1, "c:\000Glen\das is.htm", OpenMode.Input) FileOpen(2, "c:\000Glen\das is2.htm", OpenMode.Output ) Do While Not EOF(1) x = LineInput(1) If VB.Left(x, 8) = "<A NAME=" Then PrintLine(2, x) anchor(AnchSeq) = "<A HREF=" & Chr(34) & "#" & Mid(x, 10, 6) & Chr(34) & ">" & Mid(x, 12, 2) & "/" & Mid(x, 14, 2) & "/" & Mid(x, 10, 2) & "</A> " AnchSeq = AnchSeq + 1 GoTo GetTheRest End If Loop GetTheRest: Do While Not EOF(1) x = LineInput(1) If VB.Left(x, 8) = "<A NAME=" Then anchor(AnchSeq) = "<A HREF=" & Chr(34) & "#" & Mid(x, 10, 6) & Chr(34) & ">" & Mid(x, 12, 2) & "/" & Mid(x, 14, 2) & "/" & Mid(x, 10, 2) & "</A> " AnchSeq = AnchSeq + 1 End If PrintLine(2, x) Loop FileClose() Else FileOpen(4, "c:\000Glen\ord shpbu\cmonth.tx t", OpenMode.Output ) PrintLine(4, ReptMonth) FileOpen(2, "c:\000Glen\das is2.htm", OpenMode.Output ) PrintLine(2, "</BODY>") PrintLine(2, "</HTML>") FileClose() End If
FileOpen(3, "c:\000Glen\das is6.htm", OpenMode.Output ) PrintLine(3, "<HTML>") PrintLine(3, " ") PrintLine(3, "<HEAD>") PrintLine(3, " ") PrintLine(3, "<META NAME=" & Chr(34) & "GENERATOR" & Chr(34) & " CONTENT=" & Chr(34) & "VB Generated HTML" & Chr(34) & ">") PrintLine(3, "<META NAME=" & Chr(34) & "AUTHOR" & Chr(34) & " CONTENT=" & Chr(34) & "CodeAuthor " & Chr(34) & ">") PrintLine(3, "</HEAD>") PrintLine(3, " ") PrintLine(3, "<BODY>") PrintLine(3, " ") PrintLine(3, "<H1><CENTE R>My Main Company, Inc.</CENTER></H1>") PrintLine(3, " ") PrintLine(3, "<H3><CENTER>Da ily Sales Information Reports for " & ReptMonth & " 20" & RunYear & "</CENTER></H3>")
FileOpen(1, "c:\000Glen\DAO RDSHP", OpenMode.Input) FileOpen(4, "c:\000Glen\ord shpbu\DA" & RunYear & RunMon & RunDay, OpenMode.Output ) OutFile = 0 Loop1: If EOF(1) Then GoTo EndThis z = LineInput(1) PrintLine(4, z)
If VB.Left(z, 7) = "REPORT:" And InStr(z, "PAGE: 1") > 0 Then
If OutFile > 0 Then FileClose(2) OutFile = OutFile + 1 OFile = RunYear & RunMon & RunDay & VB.Right("00" & Mid(Str(OutFile ), 2), 2) & ".txt" FileOpen(2, "c:\000Glen \" & OFile, OpenMode.Output ) PrintLine(2, z) z = LineInput(1) PrintLine(4, z) RunDate = Mid(z, 11, 8) RepTitle = Trim(Mid(z, 20, 120)) PrintLine(2, z) z = LineInput(1) PrintLine(4, z) RepDate = Mid(z, InStr(z, "MONTH:") + 17, 12) ' Print #2, z$ PrintLine(3, " ") PrintLine(3, "<P>") If RepTitle = "TOTAL COMPANY SUMMARY REPORT" Then anchor(1) = "Move directly to day <A HREF=" & Chr(34) & "#" & VB.Left(OFile, 6) & Chr(34) & ">" & RunDate & "</A> " For j = 1 To AnchSeq - 1 Step 10 Print(3, anchor(j) & anchor(j + 1) & anchor(j + 2) & anchor(j + 3) & anchor(j + 4) & anchor(j + 5) & anchor(j + 6) & anchor(j + 7) & anchor(j + 8) & anchor(j + 9)) Next j PrintLine(3, " ") PrintLine(3, "<P>") PrintLine(3, "<A NAME=" & Chr(34) & VB.Left(OFile, 6) & Chr(34) & "></A>") End If PrintLine(3, "<A HREF=" & Chr(34) & "http://www.myserver.co m/reports/" & OFile & Chr(34) & ">" & RepTitle & " - " & RepDate & " (" & RunDate & ")" & "</A>") End If If z <> "-----------------------------" And z <> "============== =============== " Then If VB.Left(z, 50) = New String("=", 50) Then z = New String("=", 140) PrintLine(2, z) End If GoTo Loop1 EndThis: PrintLine(3, "<P>") FileOpen(5, "c:\000Glen\das is2.htm", OpenMode.Input) Do While Not EOF(5) x = LineInput(5) PrintLine(3, x) Loop FileClose() For j = 1 To 100 anchor(j) = "" Next j Kill("c:\000Gle n\DAORDSHP") Kill("c:\000Gle n\dasis.htm")
'Dim oFile As System.IO.File 'Dim oWrite As System.IO.Strea mWriter 'oWrite = oFile.CreateTex t("C:\sample.tx t") 'OpenText()
'Dim fs As New Scripting.FileS ystemObject Dim iLine As String Dim oLine As String Dim fs As System.IO.File Dim fs2 As System.IO.File 'Dim f As Scripting.File Dim f As System.IO.Strea mReader Dim f2 As System.IO.Strea mWriter f = fs.OpenText("c: \000Glen\dasis6 .htm") f2 = fs2.CreateText( "c:\000Glen\das is.htm")
While f.Peek <> -1 iLine = f.ReadLine() f2.WriteLine(iL ine) End While
f.Close() f2.Close() ExitCheck:
End Sub
Try running the program as a console or windows form application. Get that working first then paste it into your service. This will help you figure out if there is a problem on how you are running the service or your function.
How is your Check_for_file function called in your service? When is it triggered? Are you starting a new thread in the service to run the check_for_file?
Chris Here's where I am checking:
Private Sub Timer1_Elapsed( ByVal sender As System.Object, ByVal e As System.Timers.E lapsedEventArgs ) Handles Timer1.Elapsed Dim MyLog As New EventLog ' create a new event log ' Check if the the Event Log Exists If Not MyLog.SourceExi sts("mycompany Daily") Then MyLog.CreateEve ntSource("mycom panyDaily", "mycompany Daily") ' Create Log End If
check_for_file( )
MyLog.Source = "mycompanyDaily " ' Write to the Log MyLog.WriteEntr y("mycompany Daily Log", "This is log on " & _ CStr(TimeOfDay) , EventLogEntryTy pe.Information)
End Sub
The OnStart/OnStop events are:
Protected Overrides Sub OnStart(ByVal args() As String) ' Add code here to start your service. This method should set things ' in motion so your service can do its work. Timer1.Enabled = True End Sub Protected Overrides Sub OnStop() ' Add code here to perform any tear-down necessary to stop your service. Timer1.Enabled = False End Sub This stuff would work, but all I had it doing originally was to write events at a particular interval.
The timer is set for 480000 ticks, which should be around 5-8 minutes or so.
Re your last question - I do not know if I am or not.
I will though, take a look at running the converted app to see what's going on.
BC
As a general rule you should not do procssing inside the service thread, which is what you are doing. I have always read that you should start a new thread inside your timer_elapsed event and have the worker thread do the work.
Someone smarter than me might want to comment on this issue.
Chris
Blasting Cap wrote: The code in the app keeps blowing on the same line:
anchor(AnchSeq) = "<A HREF=" & Chr(34) & "#" & Mid(x, 10, 6) & Chr(34) & ">" & Mid(x, 12, 2) & "/" & Mid(x, 14, 2) & "/" & Mid(x, 10, 2) & "</A> "
It says that anchor(anchseq) is null.
It's not defined in the converted app, but I defined it as an array and an arraylist by me outside of that, but it gives the same message each time.
Any ideas?
BC
Chris wrote:
Blasting Cap wrote:
Chris wrote:
Blasting Cap wrote:
> I have a VB6 program that runs as an app, that I want to both > convert it to vb.net, and run it as a service on the server. > > I have been able to create the service, and what I did was to open > the vb6 document and convert it into a vb.net program. Once I did > that, the routine "check_for_file " I yanked out & put into my > service program. > > The program though - doesn't work like the existing VB6 one does. > > > I've debugged the service as it runs, and it appears to read in the > HTML file, but dies on this line: > > anchor(AnchSeq) = "<A HREF=" & Chr(34) & "#" & Mid(x, 10, 6) & > Chr(34) & ">" & Mid(x, 12, 2) & "/" & Mid(x, 14, 2) & "/" & Mid(x, > 10, 2) & "</A> " > > that is located in the GOTMONTH: section of the code. > > What happens is that it will attempt to write the file (when I open > it I get a sharing violation message), but it has only 1 byte in > the file. It must run again to put 06031201 into that file, but > that's all that it ever writes. Debugging the process, it'll step > through and appear to read everything like it should, but when it's > into that section, it just dies. No error message or anything in > the logfile that gives me any meaningful info. > > Code follows. > > Any help appreciated.... > > BC > > > Private Sub check_for_file( ) > Dim j As Short > Dim RepDate As String > Dim RepTitle As String > Dim RunDate As String > Dim OFile As String > Dim z As String > Dim OutFile As Short > Dim AnchSeq As Short > Dim ReptMonth As String > Dim RunDay As String > Dim RunMon As String > Dim RunYear As String > Dim x As String > Dim anchor As Array > > On Error GoTo FileNotThere > If FileLen("c:\000 Glen\DAORDSHP") > 0 Then GoTo FoundHim > FileNotThere: > On Error GoTo 0 > GoTo ExitCheck > > FoundHim: > > FileOpen(1, "c:\000Glen\DAO RDSHP", OpenMode.Input) > x = LineInput(1) > x = LineInput(1) > RunYear = Mid(x, 17, 2) > RunMon = Mid(x, 11, 2) > RunDay = Mid(x, 14, 2) > x = LineInput(1) > ReptMonth = Mid(x, InStr(x, "MONTH:") + 7, 9) > FileClose() > > > > On Error GoTo CmonthNotFound > FileOpen(1, "c:\000Glen\ord shpbu\cmonth.tx t", OpenMode.Input) > x = LineInput(1) > FileClose() > GoTo GotMonth > CmonthNotFound: > On Error GoTo 0 > x = "JANUARY " > GotMonth: > On Error GoTo 0 > If ReptMonth = VB.Left(x, 9) Then > AnchSeq = 2 > FileOpen(1, "c:\000Glen\das is.htm", OpenMode.Input) > FileOpen(2, "c:\000Glen\das is2.htm", OpenMode.Output ) > Do While Not EOF(1) > x = LineInput(1) > If VB.Left(x, 8) = "<A NAME=" Then > PrintLine(2, x) > anchor(AnchSeq) = "<A HREF=" & Chr(34) & "#" & > Mid(x, 10, 6) & Chr(34) & ">" & Mid(x, 12, 2) & "/" & Mid(x, 14, 2) > & "/" & Mid(x, 10, 2) & "</A> " > AnchSeq = AnchSeq + 1 > GoTo GetTheRest > End If > Loop > GetTheRest: > Do While Not EOF(1) > x = LineInput(1) > If VB.Left(x, 8) = "<A NAME=" Then > anchor(AnchSeq) = "<A HREF=" & Chr(34) & "#" & > Mid(x, 10, 6) & Chr(34) & ">" & Mid(x, 12, 2) & "/" & Mid(x, 14, 2) > & "/" & Mid(x, 10, 2) & "</A> " > AnchSeq = AnchSeq + 1 > End If > PrintLine(2, x) > Loop > FileClose() > Else > FileOpen(4, "c:\000Glen\ord shpbu\cmonth.tx t", > OpenMode.Output ) > PrintLine(4, ReptMonth) > FileOpen(2, "c:\000Glen\das is2.htm", OpenMode.Output ) > PrintLine(2, "</BODY>") > PrintLine(2, "</HTML>") > FileClose() > End If > > FileOpen(3, "c:\000Glen\das is6.htm", OpenMode.Output ) > PrintLine(3, "<HTML>") > PrintLine(3, " ") > PrintLine(3, "<HEAD>") > PrintLine(3, " ") > PrintLine(3, "<META NAME=" & Chr(34) & "GENERATOR" & > Chr(34) & " CONTENT=" & Chr(34) & "VB Generated HTML" & Chr(34) & ">") > PrintLine(3, "<META NAME=" & Chr(34) & "AUTHOR" & Chr(34) & > " CONTENT=" & Chr(34) & "CodeAuthor " & Chr(34) & ">") > PrintLine(3, "</HEAD>") > PrintLine(3, " ") > PrintLine(3, "<BODY>") > PrintLine(3, " ") > PrintLine(3, "<H1><CENTE R>My Main Company, > Inc.</CENTER></H1>") > PrintLine(3, " ") > PrintLine(3, "<H3><CENTER>Da ily Sales Information Reports > for " & ReptMonth & " 20" & RunYear & "</CENTER></H3>") > > > FileOpen(1, "c:\000Glen\DAO RDSHP", OpenMode.Input) > FileOpen(4, "c:\000Glen\ord shpbu\DA" & RunYear & RunMon & > RunDay, OpenMode.Output ) > OutFile = 0 > Loop1: > If EOF(1) Then GoTo EndThis > z = LineInput(1) > PrintLine(4, z) > > If VB.Left(z, 7) = "REPORT:" And InStr(z, "PAGE: 1") > > 0 Then > > If OutFile > 0 Then FileClose(2) > OutFile = OutFile + 1 > OFile = RunYear & RunMon & RunDay & VB.Right("00" & > Mid(Str(OutFile ), 2), 2) & ".txt" > FileOpen(2, "c:\000Glen \" & OFile, OpenMode.Output ) > PrintLine(2, z) > z = LineInput(1) > PrintLine(4, z) > RunDate = Mid(z, 11, 8) > RepTitle = Trim(Mid(z, 20, 120)) > PrintLine(2, z) > z = LineInput(1) > PrintLine(4, z) > RepDate = Mid(z, InStr(z, "MONTH:") + 17, 12) > ' Print #2, z$ > PrintLine(3, " ") > PrintLine(3, "<P>") > If RepTitle = "TOTAL COMPANY SUMMARY REPORT" Then > anchor(1) = "Move directly to day <A HREF=" & > Chr(34) & "#" & VB.Left(OFile, 6) & Chr(34) & ">" & RunDate & "</A> " > For j = 1 To AnchSeq - 1 Step 10 > Print(3, anchor(j) & anchor(j + 1) & anchor(j + > 2) & anchor(j + 3) & anchor(j + 4) & anchor(j + 5) & anchor(j + 6) > & anchor(j + 7) & anchor(j + 8) & anchor(j + 9)) > Next j > PrintLine(3, " ") > PrintLine(3, "<P>") > PrintLine(3, "<A NAME=" & Chr(34) & VB.Left(OFile, > 6) & Chr(34) & "></A>") > End If > PrintLine(3, "<A HREF=" & Chr(34) & > "http://www.myserver.co m/reports/" & OFile & Chr(34) & ">" & > RepTitle & " - " & RepDate & " (" & RunDate & ")" & "</A>") > End If > If z <> "-----------------------------" And z <> > "============== =============== " Then > If VB.Left(z, 50) = New String("=", 50) Then z = New > String("=", 140) > PrintLine(2, z) > End If > GoTo Loop1 > EndThis: > PrintLine(3, "<P>") > FileOpen(5, "c:\000Glen\das is2.htm", OpenMode.Input) > Do While Not EOF(5) > x = LineInput(5) > PrintLine(3, x) > Loop > FileClose() > For j = 1 To 100 > anchor(j) = "" > Next j > Kill("c:\000Gle n\DAORDSHP") > Kill("c:\000Gle n\dasis.htm") > > 'Dim oFile As System.IO.File > 'Dim oWrite As System.IO.Strea mWriter > 'oWrite = oFile.CreateTex t("C:\sample.tx t") > 'OpenText() > > > 'Dim fs As New Scripting.FileS ystemObject > Dim iLine As String > Dim oLine As String > Dim fs As System.IO.File > Dim fs2 As System.IO.File > 'Dim f As Scripting.File > Dim f As System.IO.Strea mReader > Dim f2 As System.IO.Strea mWriter > f = fs.OpenText("c: \000Glen\dasis6 .htm") > f2 = fs2.CreateText( "c:\000Glen\das is.htm") > > > While f.Peek <> -1 > iLine = f.ReadLine() > f2.WriteLine(iL ine) > End While > > f.Close() > f2.Close() > > > > ExitCheck: > > End Sub >
Try running the program as a console or windows form application. Get that working first then paste it into your service. This will help you figure out if there is a problem on how you are running the service or your function.
How is your Check_for_file function called in your service? When is it triggered? Are you starting a new thread in the service to run the check_for_file?
Chris
Here's where I am checking:
Private Sub Timer1_Elapsed( ByVal sender As System.Object, ByVal e As System.Timers.E lapsedEventArgs ) Handles Timer1.Elapsed Dim MyLog As New EventLog ' create a new event log ' Check if the the Event Log Exists If Not MyLog.SourceExi sts("mycompany Daily") Then MyLog.CreateEve ntSource("mycom panyDaily", "mycompany Daily") ' Create Log End If
check_for_file( )
MyLog.Source = "mycompanyDaily " ' Write to the Log MyLog.WriteEntr y("mycompany Daily Log", "This is log on " & _ CStr(TimeOfDay) , EventLogEntryTy pe.Information)
End Sub
The OnStart/OnStop events are:
Protected Overrides Sub OnStart(ByVal args() As String) ' Add code here to start your service. This method should set things ' in motion so your service can do its work. Timer1.Enabled = True End Sub Protected Overrides Sub OnStop() ' Add code here to perform any tear-down necessary to stop your service. Timer1.Enabled = False End Sub This stuff would work, but all I had it doing originally was to write events at a particular interval.
The timer is set for 480000 ticks, which should be around 5-8 minutes or so.
Re your last question - I do not know if I am or not.
I will though, take a look at running the converted app to see what's going on.
BC
As a general rule you should not do procssing inside the service thread, which is what you are doing. I have always read that you should start a new thread inside your timer_elapsed event and have the worker thread do the work.
Someone smarter than me might want to comment on this issue.
Chris
It sounds like one of your mid statements is not valid. Try running
each of them in the immedient window to see which one is crashing, or do
something like:
anchor(AnchSeq) = "<A HREF="
anchor(AnchSeq) += Chr(34) & "#" &
anchor(AnchSeq) += Mid(x, 10, 6)
This way you'll find what is really causing the problem. Also, think
about replacing "Mid" with x.Substring(10, 6) it's the .net way of doing it.
Chris This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Barry |
last post by:
object type cannot be converted to target type - i am getting this error message occuring numerous times in my task list, my project compiles and runs ok but it is a nuisance, I think Ihva eheard of this before but I cannot remember the solution, anybody got any help?
|
by: Rob Richardson |
last post by:
Greetings!
I have a VB.Net 2003 project that was originally written in VB6, converted
to VB.Net 2002, and then converted to VB.Net 2003. I am trying to handle a
form's Resize event. I put a breakpoint in it and saw that that event got
fired four times before the form's Load event got fired! I then saw that I
have the following routine in the form's code:
Private Const WM_SHOWWINDOW = &H18
Private m_loaded As Boolean
|
by: Jim in Arizona |
last post by:
I'm learning form an ASP.NET 1.0 book and I tried out some code that returns
this error:
Compiler Error Message: BC30311: Value of type 'Integer' cannot be converted
to 'ASP.multiclasses_aspx.VehicleKey'.
Source Error:
Line 106:
|
by: John |
last post by:
I'm attempting to launch a converted window through the drop down menu in
order to assess the functionality that the conversion wizard was able to
preserve. However, the function FormShow(frmName.DefInstance) is not taking
the newly converted class frmNameDetail as input. We noticed that most new
forms inherit from Controls.BaseForm so I tried that change. Is there any
other refitting that needs to be done for converted form classes?
...
|
by: GaryDean |
last post by:
(my original post was inaccurate but this post accurately describes what I
think is a very bad vs2005 bug)
short description...
Deleting a dataset and recreating it from the dataadapter causes VS.Net 2005
to render the associated .resx and .vb file inoperative.
detail...
I converted an asp 1.1 vb.net app using the vs2005 conversion wizard and
then retested the app after conversion.
| |
by: larpup |
last post by:
I've written an app in A2003 only to find out that some customers are
presently using A2000.
Rather than place a runtime on their computer, it would be more
convenient to convert appt to A2000 if possible. I know how to convert
the file format, but when running an A2000 instance, if receive
"recordset not updateable". Is this possible?
Lar
|
by: rdemyan via AccessMonster.com |
last post by:
I've converted my application from A2K format to A2003 format.
I tried to follow Allen Browne's protocol in getting my app into A2003
(although I was unable to find informtion on the conversion process). Lots
of decompiling and lots of compacting of the original application in A2000.
Then the app was opened in A2003 and compacted, decompiled and compacted.
Next I imported everything into a blank A2003 database. Then this db was...
|
by: imrosie |
last post by:
Hello,
I have a form(PrintPreviewInvoices) that displays past invoices (in a listbox). I added a combo box control in order to filter timeframes;(today, this week, last week, this month, last month and all).
I copied this macro filter from another db and then converted it to a function module (called PrintPreviewInvoices) in VB. I'm trying to properly set it up to be used as an 'On Change' event, but not real sure how to get the results I...
|
by: vlsidesign |
last post by:
Newbie question: 0 converted to 0.0 for float variable?
If I have the following code,
float myTotal;
myTotal = 0;
will C automatically add a decimal point and at least one zero to the
right of the decimal place? I am expecting that 0 will become at least
0.0 or maybe something with more zeros.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |