Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 250
  • Last Modified:

Is it possible to output labels to html????

I am using VB6 and was wondering if it is possible to output labels (the contents of labels) to html so you can view them in your browser, or if you can output the form or somehow output it to html and how??

Cheers

0
On_The_Level
Asked:
On_The_Level
1 Solution
 
dsulkarCommented:
you are just trying to write the lble caption information to an HTML file correct
0
 
onemorecokeCommented:
You could use this:

open "c:\yourfile.html" for output as #1
print#1, "Your name"
print#1, "Your address"
print#1, "Your city/state/zip"
close#1

This will create an HTML file on your c drive.

Then you can click on the HTML file you created when you are done.

If you want the browser to come up after the processing is done, you can use the ShellExecute command to bring up a browser automatically.  If you need to know more about this, let me know.

onemorecoke
0
 
jimbobmcgeeCommented:
How do you want your labels to be displayed?  As an extension of onemorecoke's answer, you could output your file as such:

     Open "x:\mypath\myhtmlfile.htm" For Output as #1

             Print #1, "<HTML><HEAD><TITLE>My Labels</TITLE></HEAD><BODY>"

             For Each ctl In myForm.Controls

                   If TypeOf ctl Is Label Then Print #1, "<P>" & ctl.Caption & "</P>"

             Next ctl

             Print #1, "</BODY></HTML>"

     Close #1

HTH

J.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
jimbobmcgeeCommented:
You may need to change the following to

     If TypeOf ctl Is Label...

to

     If TypeOf ctl Is VB.Label...

Rgds.
J.
0
 
On_The_LevelAuthor Commented:
Cheers

I am creating an invoice with the data so il looking to have it output in a invoice way i u know what i mean.
0
 
jimbobmcgeeCommented:
Below is a comment I posted in another PAQ, a while back, regarding writing HTML invoices -- it should apply to you with a little tweaking (e.g. changing my variable names to yourLabel.Caption)

HTH

J.

--------------------------------------------
Last time i needed to print an invoice, I outputted it to a text file, using some HTML formatting I knew, and printed it from a browser control, e.g.:

     Type Item
              Number as Long
              Name as String
              Quantity as Integer
              UnitPrice as Currency
     End Type

     Dim arrItems(1 To 5) as Item
     Dim curSubtotal as Currency
     Dim sngTax as Single

     sngTax = 0.175             '<--- UK SALES TAX/VAT MULTIPLIER (17.5%)

     Open App.Path & "\Invoices\" & lngInvoiceNo & ".htm" for Output as #1

              Print #1, "<HTML>"
              Print #1, "<HEAD><TITLE>Invoice #" & lngInvoiceNo & "</TITLE></HEAD>"
              Print #1, "<BODY>"
              Print #1, "<TABLE>
              Print #1, "<TR><TD>Customer Name:</TD><TD>" & strCustomerName & "</TD></TR>"
              Print #1, "<TR><TD>Customer Address:</TD><TD>" & strCustomerAddress1 & "<BR>" & _
                                                                                                 strCustomerAddress2 & "<BR>" & _
                                                                                                 strCustomerTown & "<BR> & _
                                                                                                 strCustomerCounty & "<BR> & _
                                                                                                 strCustomerPostCode & "</TD></TR>
              '...YOUR HEADER FIELDS
             
              Print #1, "</TABLE>"
              Print #1, "<HR>"
              Print #1, "<TABLE>"
              Print #1, "<TR><TD>No</TD><TD>Desc</TD><TD>Unit</TD><TD>Qty</TD><TD>Total</TD></TR>
             
              For i = LBound(arrItems) to UBound(arrItems)

                    Print #1, "<TR><TD>" & arrItems(i).Number & "</TD>" & _
                                          "<TD>" & arrItems(i).Name & "</TD>" & _
                                          "<TD>" & arrItems(i).UnitPrice & "</TD>" & _
                                          "<TD>" & arrItems(i).Quantity & "</TD> " & _
                                          "<TD>" & arrItems(i).Quantity * arrItems(i).UnitPrice & "</TD></TR>"

                    curSubtotal = curSubtotal + (arrItems(i).Quantity * arrItems(i).UnitPrice)

              Next i

              Print #1, "<TR><TD colspan=4>Subtotal:</TD><TD>" & curSubtotal & "</TD></TR>"
              Print #1, "<TR><TD colspan=4>Tax:</TD><TD>" & curSubtotal * sngTax & "</TD></TR>"
              Print #1, "<TR><TD colspan=4>Total:</TD<TD>" & curSubtotal+(curSubtotal*sngTax) & "</TD></TR>"

              Print #1, "</TABLE>"
              Print #1, "</BODY>"
              Print #1, "</HTML>"

      Close #1

      WebBrowser1.Navigate(App.Path & "\Invoices\" & lngInvoiceNo & ".htm")
                                                                                'SHOW THE GENERATED INVOICE
     
      WebBrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0
                                                                                'PRINT THE CONTENTS OF THE BROWSER OBJECT

You'd have to change the variables, etc, to match your data, but this was the simplest method I found (so long as you know a little HTML).

HTH

J.
0
 
On_The_LevelAuthor Commented:
Say i wanted to output a line or add a line to the html file is that possible?
0
 
jimbobmcgeeCommented:
The HTML code for a simple line is '<HR>' so, if using the above code, add a line like:

    Print #1, "<HR>"

at the point that you want the line to be...

J.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now