And then it loads the text file and makes an HTML report on an external browser. Thats all good.
But i want another button under that button that does exatly the same thing but it displays the html in a form using Web Browser for vb.net. 2008 version by the way.
so i have two buttons, depending on what the user pushes. same html is produced, but one is in external browser while the other is in form.
Here is code i used for first button
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sFilename As String
sFilename = ("E:\RMIT WORK\Testing\" & txtOfficeID.Text & ".txt")
If Not File.Exists(sFilename) Then
MsgBox("IDIOT'")
Else
Call LoadHTML()
Call makeHTMLReport()
End If
End Sub
Private Sub LoadHTML()
Dim sFileName As String
Dim sFields(iMax) As String ' store each field stored in a record
Dim iNumRecords As Integer ' number of records read from the file
Dim sLine As String
sFileName = ("E:\RMIT WORK\Testing\" & txtOfficeID.Text & ".txt")
Dim sr_RepFile As StreamReader
sr_RepFile = File.OpenText(sFileName)
iNumRecords = 0
'read the file line by line
sLine = sr_RepFile.ReadLine
While sLine <> Nothing And iNumRecords < iMaxConsignments
sFields = Split(sLine, "|")
sDutyManagerIDs(iNumRecords) = sFields(0)
sConsignmentNumbers(iNumRecords) = sFields(1)
sShipmentMethods(iNumRecords) = sFields(2)
sExpectedDepartureDates(iNumRecords) = CDate(sFields(3))
sExpectedArrivalDates(iNumRecords) = CDate(sFields(4))
sShipmentDurations(iNumRecords) = CInt(sFields(5))
sShipmentCosts(iNumRecords) = CInt(sFields(6))
iNumRecords = iNumRecords + 1
sLine = sr_RepFile.ReadLine
End While
End Sub
Private Sub makeHTMLReport()
'Variables
Dim sFilename As String
Dim sw_RepFile As StreamWriter 'Need a Streamriter to write HTML code into a textfile
sFilename = ("E:\RMIT WORK\Testing\" & txtOfficeID.Text & ".htm")
Dim sLine As String
Dim iFoundIndexPosition As Integer = 0
Dim sDutyManagerID As String
Dim sConsignmentNumber As String
Dim sShipmentMethod As String
Dim sDepartureDate As String
Dim sArrivalDate As String
Dim sShipmentDuration As String
Dim sShipmentCost As String
sw_RepFile = New StreamWriter(sFilename)
sw_RepFile.WriteLine("<HTML>")
sw_RepFile.WriteLine("<HEAD>")
sw_RepFile.WriteLine("<TITLE>Office Consignment File: IT99</TITLE>")
sw_RepFile.WriteLine("</HEAD>")
sw_RepFile.WriteLine("<BODY>")
sw_RepFile.WriteLine("<h1> Consignment File for Office IT99 </h1>")
sw_RepFile.WriteLine("<IMG SRC=E:\TPXELogo.png HEIGHT=100 WIDTH=200><P>")
sw_RepFile.WriteLine("<TABLE BORDER=1>")
sw_RepFile.WriteLine("<TR><TH>Duty Manager ID</TH><TH>Consignment Number</TH><TH>Shipment Method</TH><TH>Expected Departure Date</TH><TH>Expected Arrival Date</TH><TH>Shipment Duration</TH><TH>Shipment Cost</TH></TR>")
'Looping through Office Consignment file and pick up data
Do While sConsignmentNumbers(iFoundIndexPosition) <> ""
sDutyManagerID = sDutyManagerIDs(iFoundIndexPosition)
sConsignmentNumber = sConsignmentNumbers(iFoundIndexPosition)
sShipmentMethod = sShipmentMethods(iFoundIndexPosition)
sDepartureDate = sExpectedDepartureDates(iFoundIndexPosition)
sArrivalDate = sExpectedArrivalDates(iFoundIndexPosition)
sShipmentCost = sShipmentCosts(iFoundIndexPosition)
sShipmentDuration = sShipmentDurations(iFoundIndexPosition)
iFoundIndexPosition = iFoundIndexPosition + 1
'Declare sLine as a record from the textfile to be writen on the webpage.
sLine = "<TR><TD>" & sDutyManagerID & "</TD><TD>" & sConsignmentNumber & "</TD><TD>" & sShipmentMethod & "</TH><TH>" & sDepartureDate & "</TH><TH>" & sArrivalDate & "</TH><TH>" & sShipmentDuration & "</TH><TH>" & sShipmentCost & "</TH></TR>"
sw_RepFile.WriteLine(sLine)
Loop
sw_RepFile.WriteLine("</TABLE>")
sw_RepFile.WriteLine("<P>") 'Jumps to a new line
sw_RepFile.WriteLine("<A HREF=http://www.rmit.edu.au> Jump to RMIT Home Page </A>")
sw_RepFile.WriteLine("</BODY>")
sw_RepFile.WriteLine("</HTML>")
sw_RepFile.Close()
System.Diagnostics.Process.Start(sFilename)

New Topic/Question
Reply




MultiQuote




|