B
Blasting Cap
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:\000Glen\DAORDSHP") > 0 Then GoTo FoundHim
FileNotThere:
On Error GoTo 0
GoTo ExitCheck
FoundHim:
FileOpen(1, "c:\000Glen\DAORDSHP", 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\ordshpbu\cmonth.txt", 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\dasis.htm", OpenMode.Input)
FileOpen(2, "c:\000Glen\dasis2.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\ordshpbu\cmonth.txt", OpenMode.Output)
PrintLine(4, ReptMonth)
FileOpen(2, "c:\000Glen\dasis2.htm", OpenMode.Output)
PrintLine(2, "</BODY>")
PrintLine(2, "</HTML>")
FileClose()
End If
FileOpen(3, "c:\000Glen\dasis6.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><CENTER>My Main Company, Inc.</CENTER></H1>")
PrintLine(3, " ")
PrintLine(3, "<H3><CENTER>Daily Sales Information Reports for "
& ReptMonth & " 20" & RunYear & "</CENTER></H3>")
FileOpen(1, "c:\000Glen\DAORDSHP", OpenMode.Input)
FileOpen(4, "c:\000Glen\ordshpbu\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.com/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\dasis2.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:\000Glen\DAORDSHP")
Kill("c:\000Glen\dasis.htm")
'Dim oFile As System.IO.File
'Dim oWrite As System.IO.StreamWriter
'oWrite = oFile.CreateText("C:\sample.txt")
'OpenText()
'Dim fs As New Scripting.FileSystemObject
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.StreamReader
Dim f2 As System.IO.StreamWriter
f = fs.OpenText("c:\000Glen\dasis6.htm")
f2 = fs2.CreateText("c:\000Glen\dasis.htm")
While f.Peek <> -1
iLine = f.ReadLine()
f2.WriteLine(iLine)
End While
f.Close()
f2.Close()
ExitCheck:
End Sub
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:\000Glen\DAORDSHP") > 0 Then GoTo FoundHim
FileNotThere:
On Error GoTo 0
GoTo ExitCheck
FoundHim:
FileOpen(1, "c:\000Glen\DAORDSHP", 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\ordshpbu\cmonth.txt", 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\dasis.htm", OpenMode.Input)
FileOpen(2, "c:\000Glen\dasis2.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\ordshpbu\cmonth.txt", OpenMode.Output)
PrintLine(4, ReptMonth)
FileOpen(2, "c:\000Glen\dasis2.htm", OpenMode.Output)
PrintLine(2, "</BODY>")
PrintLine(2, "</HTML>")
FileClose()
End If
FileOpen(3, "c:\000Glen\dasis6.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><CENTER>My Main Company, Inc.</CENTER></H1>")
PrintLine(3, " ")
PrintLine(3, "<H3><CENTER>Daily Sales Information Reports for "
& ReptMonth & " 20" & RunYear & "</CENTER></H3>")
FileOpen(1, "c:\000Glen\DAORDSHP", OpenMode.Input)
FileOpen(4, "c:\000Glen\ordshpbu\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.com/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\dasis2.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:\000Glen\DAORDSHP")
Kill("c:\000Glen\dasis.htm")
'Dim oFile As System.IO.File
'Dim oWrite As System.IO.StreamWriter
'oWrite = oFile.CreateText("C:\sample.txt")
'OpenText()
'Dim fs As New Scripting.FileSystemObject
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.StreamReader
Dim f2 As System.IO.StreamWriter
f = fs.OpenText("c:\000Glen\dasis6.htm")
f2 = fs2.CreateText("c:\000Glen\dasis.htm")
While f.Peek <> -1
iLine = f.ReadLine()
f2.WriteLine(iLine)
End While
f.Close()
f2.Close()
ExitCheck:
End Sub