CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12
  1. #1
    Join Date
    Oct 2006
    Location
    slavia
    Posts
    42

    Arrow how to enable HTML objects, such as TABLE, FORM,, etc in VB 6

    dear all,
    i'd like to apologize if this question incidentally have been asked before.

    i am building an inventory application.
    I have one trouble - which until now not solved yet - in delivering the view of the data.
    I wonder, if there is any way to view the data with HTML component such as <TABLE> in vb 6 ? the data will be taken from MSSQL using ADO, and will be shown in a VB6 form, inside a table, but the table is not a DataGrid, or FlexGrid, or another grid, because i have a hard experience in programming those GRID things. I think the solution is, If only I can insert the HTML TABLE object into one of my FORM, and from that FORM i can control or modify the <TABLE> value, spanning the column, inserting an event, just like HTML things ..

    i'd be very thankful in every reply

    rgrds,


    szpilman

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: how to enable HTML objects, such as TABLE, FORM,, etc in VB 6

    Maybe using a WebBrowser control? That would dispay the html, but you'd have to edit it using an editor, or from within VB, and then reload a new page.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Jan 2003
    Location
    7,107 Islands
    Posts
    2,487

    Re: how to enable HTML objects, such as TABLE, FORM,, etc in VB 6

    yes, using the webbrowser control you can display an HTML file or even create the HTML document interactively.. here's my sample code, the first line instantiates the document property of the control.. hope it helps.

    Code:
      wbb.Navigate "about:blank"
      
      wbb.Document.open
        
      wbb.Document.writeln "<html><body>"
      wbb.Document.writeln "<head>" & vbCrLf & _
                           "<style type=""text/css"">" & vbCrLf & _
                           "td {white-space: nowrap;}" & vbCrLf & _
                           "</style>" & vbCrLf & _
                           "</head>"
      
      wbb.Document.writeln "<table border=""1"" cellspacing=""0"">" & vbCrLf & _
                           "<thead style=""font: bold 14px arial; color: blue;"">" & vbCrLf & _
                           "<tr>" & vbCrLf & _
                           "  <td>Item #</td>" & vbCrLf & _
                           "  <td>Quantity</td>" & vbCrLf & _
                           "  <td>Code</td>" & vbCrLf & _
                           "  <td>Description</td>" & vbCrLf & _
                           "</tr>" & vbCrLf & _
                           "<tbody style=""font: 10px arial;"">" & vbCrLf & _
                           "<tr>" & vbCrLf & _
                           "  <td>1</td>" & vbCrLf & _
                           "  <td>50</td>" & vbCrLf & _
                           "  <td>USBFD2G</td>" & vbCrLf & _
                           "  <td>USB Flash Drive 2GB</td>" & vbCrLf & _
                           "</tr>" & vbCrLf & _
                           "<tr>" & vbCrLf & _
                           "  <td>2</td>" & vbCrLf & _
                           "  <td>15</td>" & vbCrLf & _
                           "  <td>LCDMON</td>" & vbCrLf & _
                           "  <td>TFT LCD Monitor</td>" & vbCrLf & _
                           "</tr>" & vbCrLf & _
                           "</table>"
      wbb.Document.writeln "</body></html>"
                           
      wbb.Document.Close
    Busy

  4. #4
    Join Date
    Oct 2006
    Location
    slavia
    Posts
    42

    Re: how to enable HTML objects, such as TABLE, FORM,, etc in VB 6

    thnx thread1 and david.
    the web browser control work well.
    but it raise another question is..
    suppose i have made the TABLE succesfully, then
    how to make that HTML TABLE can interact with the VB6 FORM ?
    lets say FORM1 contain the TABLE from WEB BROWSER control,
    if i right click on the cell, there is an event that will show another form, but the form is from VB6 not HTML page.

    thnk U.

    rgrds,

    szpilman

  5. #5
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: how to enable HTML objects, such as TABLE, FORM,, etc in VB 6

    @Thread1: I seem to get an error when trying wbb.Document.open:
    Runtime error 438, saying method is not supported (in german).
    Any Idea? Because I'd like to try that piece of code.

  6. #6

    Re: how to enable HTML objects, such as TABLE, FORM,, etc in VB 6

    how to make that HTML TABLE can interact with the VB6 FORM ?
    As far as i can remember, making interaction between your VB application and HTML content is one side only. If you can easily and dinamically write an HTML file based on a SQL table content and put it in a webbrowser control, like shown in the samples below. Reading the content of the HTML in the control to interact with your VB, is another issue to which i see no easy solution.

    If someone know, please tell us. I'm also very interested...
    David Domingues at [email protected]. Feel free to visit http://www.webrickco.com

  7. #7
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: how to enable HTML objects, such as TABLE, FORM,, etc in VB 6

    Well, I've used DOM (Document Object Model) to scrape info off a webpage, as well as put info back. You can get the text easily.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  8. #8
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: how to enable HTML objects, such as TABLE, FORM,, etc in VB 6

    Here is an older sample. I hope they haven't changed the webpage layout, or it wouldl need more work. In any case, it won't work for any other webpage, but you can see how it's done.

    If you have the Firefox Browser, it has on the TOOLS MENU, a link to the DOM Parser. It lets you see the underlying Markup Language in most webpages (except some PHP and ASP sites).
    Attached Files Attached Files
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  9. #9
    Join Date
    Sep 2006
    Posts
    635

    Re: how to enable HTML objects, such as TABLE, FORM,, etc in VB 6

    I think,you can use this piece of code.
    where 'wb' is Microsoft Internet Controls, to find press CTRL + T
    Code:
    dim rs as new adodb.recordset
    dim For_ValueNull as string
    dim RStoHTML  as string
    set rs=new adodb.recordset
     rs.ActiveConnection =strcon
     rs.Source = "select campo1,campo2 from tabla"
     rs.Open
    
    For_ValueNull="(NULL)" 
    RStoHTML = rs.GetString(adClipString, -1, "</TD><TD>", "</TD></TR>" & vbCrLf & "<TR><TD>", For_ValueNull)
    RStoHTML = "<TR><TD>" & Left(RStoHTML, Len(RStoHTML) - 8)
    RStoHTML = "<table bgcolor='#0078B3' border='1' cellspacing='0' >" & vbCrLf & _
    					"<thead style='font: bold 14px arial; color: black;'>" & vbCrLf & _
    					"<tr bgcolor='#8ABEF2'><td><font color='#E8FFE8'>Tittle1</font></td><td><font color='#E8FFE8'>title2</font></td></font></tr>" & RStoHTML &
     "</TABLE>"
    set rs=nothing
    wb.Navigate "about:blank"
    wb.Document.Open
    wb.Document.writeln RStoHTML
    I hope it helps you
    Last edited by hensa22; January 20th, 2007 at 01:38 PM.

  10. #10
    Join Date
    Jan 2003
    Location
    7,107 Islands
    Posts
    2,487

    Re: how to enable HTML objects, such as TABLE, FORM,, etc in VB 6

    Quote Originally Posted by szpilman
    thnx thread1 and david.
    the web browser control work well.
    but it raise another question is..
    suppose i have made the TABLE succesfully, then
    how to make that HTML TABLE can interact with the VB6 FORM ?
    lets say FORM1 contain the TABLE from WEB BROWSER control,
    if i right click on the cell, there is an event that will show another form, but the form is from VB6 not HTML page.

    thnk U.

    rgrds,

    szpilman

    well, thanks to the control's TitleChange event . .. the event fires whenever there is a change in the document.title or whenever you assign a value to this property. since this event also fires upon load of the document, perhaps you can declare your own format that can be filtered out.. here is the revised code, see how i raised the event in the script

    Code:
      wbb.Navigate "about:blank"
      
      wbb.Document.open
        
      wbb.Document.writeln "<html>" & vbCrLf & _
                           "<head>" & vbCrLf & _
                           "<style type=""text/css"">" & vbCrLf & _
                           "td {white-space: nowrap;}" & vbCrLf & _
                           "</style>" & vbCrLf & _
                           "<script type=""text/javascript"">" & vbCrLf & _
                           "document.onmousedown = function () { if (event.button == 2) { this.title = 'RIGHT CLICK DATA: ' + this.elementFromPoint(event.x, event.y).innerHTML; return false; } }" & vbCrLf & _
                           "</script>" & vbCrLf & _
                           "</head>"
      
      wbb.Document.writeln "<body oncontextmenu=""return false;"">" & vbCrLf & _
                           "<table border=""1"" cellspacing=""0"">" & vbCrLf & _
                           "<thead style=""font: bold 14px arial; color: blue;"">" & vbCrLf & _
                           "<tr>" & vbCrLf & _
                           "  <td>Item #</td>" & vbCrLf & _
                           "  <td>Quantity</td>" & vbCrLf & _
                           "  <td>Code</td>" & vbCrLf & _
                           "  <td>Description</td>" & vbCrLf & _
                           "</tr>" & vbCrLf & _
                           "<tbody style=""font: 10px arial;"">" & vbCrLf & _
                           "<tr>" & vbCrLf & _
                           "  <td>1</td>" & vbCrLf & _
                           "  <td>50</td>" & vbCrLf & _
                           "  <td>USBFD2G</td>" & vbCrLf & _
                           "  <td>USB Flash Drive 2GB</td>" & vbCrLf & _
                           "</tr>" & vbCrLf & _
                           "<tr>" & vbCrLf & _
                           "  <td>2</td>" & vbCrLf & _
                           "  <td>15</td>" & vbCrLf & _
                           "  <td>LCDMON</td>" & vbCrLf & _
                           "  <td>TFT LCD Monitor</td>" & vbCrLf & _
                           "</tr>" & vbCrLf & _
                           "</table>"
      wbb.Document.writeln "</body></html>"
                           
      wbb.Document.Close
    Code:
    Private Sub wbb_TitleChange(ByVal Text As String)
      If Text Like "RIGHT CLICK DATA:*" Then
        MsgBox Text    
      End If
    End Sub
    Busy

  11. #11
    Join Date
    Jan 2003
    Location
    7,107 Islands
    Posts
    2,487

    Re: how to enable HTML objects, such as TABLE, FORM,, etc in VB 6

    Quote Originally Posted by WoF
    @Thread1: I seem to get an error when trying wbb.Document.open:
    Runtime error 438, saying method is not supported (in german).
    Any Idea? Because I'd like to try that piece of code.
    is your "wbb" a web browser control (reference : microsoft internet controls)?
    Busy

  12. #12
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: how to enable HTML objects, such as TABLE, FORM,, etc in VB 6

    Yes, it is. What am I doing wrong?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured