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??


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

you are just trying to write the lble caption information to an HTML file correct
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"

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.

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


Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

You may need to change the following to

     If TypeOf ctl Is Label...


     If TypeOf ctl Is VB.Label...

On_The_LevelAuthor Commented:

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.
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)



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
                                                                                '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).



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
On_The_LevelAuthor Commented:
Say i wanted to output a line or add a line to the html file is that possible?
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...

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.