Results 1 to 21 of 21

Thread: [RESOLVED] How control web component in VB6

Hybrid View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2005
    Posts
    105

    Resolved [RESOLVED] How control web component in VB6

    Hi Dears,
    I am working in a money exchange. I developed a money transfer program for the company.

    Now my company has started an online money transfer service up on an agreement with EzRemit service which offers this service.

    EzRemit service is done through their e-commercial web site www.ezremit.net, in ASP Classic

    So in my project I coluld to call this web site using webbrowser control of VB6. Now I want to manipulate programitcally the data we put in the fields of the web site. That is the same data we want to also store in our server while it goes into remote server of the site.

    Here an another company who also deals with the EzRemit service has a program with this facility. The site is opened in a VB6 program and this program manipulate and store the data entered in the fields of the web site.
    Thus my manager requested me to develop same facility in our program also. And I have no way to contatct with the programmer who did for other company.

    So I request you also to help me regarding this by providing idea or code to do the same. I think it is done in VB6 by the help of ASP.

    Any way I hope your help urgently

    With regards,
    Klari

  2. #2
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011

    Re: How control web component in VB6

    Quote Originally Posted by nasreen
    Hi Dears,
    I am working in a money exchange. I developed a money transfer program for the company.

    Now my company has started an online money transfer service up on an agreement with EzRemit service which offers this service.

    EzRemit service is done through their e-commercial web site www.ezremit.net, in ASP Classic

    So in my project I coluld to call this web site using webbrowser control of VB6. Now I want to manipulate programitcally the data we put in the fields of the web site. That is the same data we want to also store in our server while it goes into remote server of the site.

    Here an another company who also deals with the EzRemit service has a program with this facility. The site is opened in a VB6 program and this program manipulate and store the data entered in the fields of the web site.
    Thus my manager requested me to develop same facility in our program also. And I have no way to contatct with the programmer who did for other company.

    So I request you also to help me regarding this by providing idea or code to do the same. I think it is done in VB6 by the help of ASP.

    Any way I hope your help urgently

    With regards,
    Klari
    So you need to manipulate data in textboxes of a web page?

    I have done this some time back... let me know.. if you want this..

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: How control web component in VB6

    If you want to post data to a HTML form you should look into the ServerXMLHTTP object of the MSXML component.

  4. #4
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871

    Re: How control web component in VB6

    If you have some more details on the page you're wanting to fill in, I'll see what I can do for you. Also, read the second article in my signature, it covers manipulation of webpages.
    Author for Visual Basic Web Magazine

    My articles on the Web Browser Control:
    Using the Web Browser Control & Using the DHTML Document Object Model

    The examples referenced in the articles can be found here:

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Apr 2005
    Posts
    105

    Re: How control web component in VB6

    Hi
    Dear Sir

    Read your reply to my post in vbfourms,

    Thanks a lot of for your directions. Really it was great help for me.

    Any way my problem is not solved yet.

    Here I have mail you to michielmeulendijk@hotmail.com two screen shots of my project in Jpg format. I think you may considert it and help me.

    My project is for an Exchange company doing online money transactions.
    As you can see in my first screenshot the first page of the web is opend in a from in my project using web control. In this page we put the custmer informations. Now what I really want is when I click the proceed button of the web page I want to save the data typed in the fields of web page in my local database also.
    I want the same facility in my second page also. This page used to put beneficiary informations. So I want to save the data in my system also at the time it is saved in remoter server.
    Pls keep in mind that I have no any privilage to edit the website. It is not mine and it is of a forieng company.
    How can I slove my problem.
    Hoping your directions, codes, a smiple project of any pages like yahoo mails login page.

    With regards,
    nasreen
    thanks once again

  6. #6
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871

    Re: How control web component in VB6

    It's very well possible to save the data from the webpage before it's being submitted. As I suggested in my previous post, you should use the Document Object Model; it provides you with a hierarchical interface to control the webpage. Let me explain.

    I found the website at http://www.ezremit.com.kw/ and since I don't have any customer ID I can't log in. If you look at the HTML source of the page you'll see that all textboxes are input elements (<input type=text...). The page has been well programmed, all elements have names and unique ID's (id="agentcode" for example). To get the text of the first textbox (Agent Code), you can use this code:
    VB Code:
    1. MsgBox WebBrowser1.Document.getElementById("agentcode").value
    I strongly suggest you read the second article in my signature (Using the DHTML Document Object Model). It clearly explains the concept of the DOM, you'll understand it much better.

    Also, if you want me to help you more, you'll have to send me login information so I can get past the first page. Then I can take a more detailed look at the HTML of the other pages.
    Author for Visual Basic Web Magazine

    My articles on the Web Browser Control:
    Using the Web Browser Control & Using the DHTML Document Object Model

    The examples referenced in the articles can be found here:

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Apr 2005
    Posts
    105

    Re: How control web component in VB6

    Hi TheVader,

    Special thanks to you for your valuable directions.
    Now I got the idea to retieve data from web components. Especially your code sample is very useful.
    Here I also expect to describe me how can I catch this data before it is submitting.

    I used the event "BeforeNavigate2" of the WebBrowser but this have many other problems. Especially when click the back button of the navigator.

    So is there any idea to trace with submit button click action. For example I want to retrieve the data when the Login button is clicked in www.ezremit.com.kw

    Regarding this I have another problem also, that I want to set focus to a field.
    I tried with this code
    WebBrowser1.Document.getElementById("agentcode").focus
    and
    WebBrowser1.Document.getElementById("agentcode").focus()

    The first one dosn't work and second one shows syntax error.

    So how can I do it. How can I set focus into agentcode field.

    I read your DHTML DOM documentation. This article opened a wide possiblities before me. But I didn't get a satsified solution for the above mentioned problem.

    Expecting your detailed reply

    Regarding to the login details really I am also ignorent about it. I am only a programmer for this company. Whenever I need to login, the manager do it and type the password and so.

    With regards,
    klari

  8. #8
    eltiT resU motsuC Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: How control web component in VB6

    Just a FYI tip: (Vader will like this too )

    dont WithEvents the Document.. hit the Form itself it makes it easier to grab the onsubmit
    same of "watching" for the submit on google
    VB Code:
    1. 'Added Reference to HTML Object Library
    2. Dim WithEvents wFORM As HTMLFormElement
    3.  
    4.  
    5. Private Sub Form_Load()
    6.     WebBrowser1.Navigate "www.google.com"
    7. End Sub
    8.  
    9. Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    10. If (pDisp Is WebBrowser1.Application) Then
    11.     Set wFORM = WebBrowser1.Document.Forms(0)
    12. End If
    13. End Sub
    14.  
    15.  
    16. Private Function wFORM_onsubmit() As Boolean
    17.     MsgBox WebBrowser1.Document.getElementById("q").Value
    18. End Function

    there are lots of "events" in a form.. and the onsubmit will allow you to nab all the fields before it does anything else
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Apr 2005
    Posts
    105

    Re: How control web component in VB6

    Hi Mr. TheVader

    Hope u fine.

    After an intervel I am still in need of your help and guidance in my career that always give me hope in your kindness. Surely you opened a wide range of hopes in my carreer world.

    Now I am facing a new problem in my new project.
    In this project, the web page has read only field when I double click that filed a popup explorer window come.
    The script is written in JavaScript , here is the HTML tag details of that web site


    <TD><INPUT id=agentCd
    ondblclick="callLov('addRemitInfo_files/lovAgentCd.htm','300','316')"
    readOnly maxLength=10 name=agentCd></TD>



    Now I want to cancel this action programitically in my project.
    I wrote this code


    Private Function objDocument_ondblclick() As Boolean
    On Error GoTo Last

    objDocument_ondblclick = False

    Exit Function
    Last:
    End Function


    But this code is not working and the popup window still come.
    So, if possible pls suggest a solution to stop this action or to close the popup window programitically from my project.

    I send a mail to you with attachment of that web site I saved.

    Waiting for your best support

    Nasreen

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Apr 2005
    Posts
    105

    Re: How control web component in VB6

    Hi all,

    Is there any idea to click the select component of an HTML page programitically

    Here is the HTMT code

    HTML Code:
    <td width="83%" align=left nowrap><font face="Times New Roman, Times, serif"> 
    			<select name=cboPrimary size=1 onChange="RemoveOptionAndSubmit(cboSecondary)" style="width=350px;">
    <option value="003"  >ALLIED BANKING CORPORATION - $ BTB (USD  )</option> 
    <option value="004"  >ALLIED BANKING CORPORATION - PESO BTB (PHP  )</option> 
    <option value="008"  >ALLIED BANKING CORPORATION - PESO DTOD (PHP  )</option> 
    <option value="052"  >BANK OF THE PHILIPPINE ISLAND (USD  )</option> 
    <option value="049"  >BANK OF THE PHILLIPINE ISLAND (PHP  )</option> 
    <option value="179"  >EQUITABLE BANK / PCI (PHP  )</option> 
    <option value="175"  >METRO BANK (PHP  )</option> 
    <option value="176"  >METRO BANK - $ (USD  )</option> 
    <option value="177"  >PHILIPPINE NATIONAL BANK (PHP  )</option> 
    <option value="178"  >PHILIPPINE NATIONAL BANK - $ (USD  )</option> 
              	</select>
              	</font>
    		 </td>
    When one of bank is selected, the branches of that bank will be lsited.

    Now I want to do this process programtically.

    Here I used this code:

    VB Code:
    1. Dim BankIndex as Integer
    2. Dim BankName as String
    3. BankIndex  =  5
    4. browser.Document.getElementById("cboPrimary").selectedIndex = BankIndex

    This code select the expected bank BANK OF THE PHILIPPINE ISLAND (USD )

    But the page not lists the branch of this bank. It still remain wihout any action.

    Is there any suggession to solve this problem

    With regards,
    Nasreen

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Apr 2005
    Posts
    105

    Re: How control web component in VB6

    Hi Thevader and All,

    How we can programitically click a button or link of a web page viewed in FRAMED web page.

    I use for a web page without frame the following code :

    VB Code:
    1. Dim WithEvents objDocument As HTMLDocument
    2.  
    3. Private Sub browser_DownloadComplete()
    4. Set objDocument = browser.Document
    5. End Sub

    This code work fine and without error.

    But I want to do the same function in a web page with three frames, to control the mouse click programitically.

    I used the the following code

    VB Code:
    1. Dim WithEvents objFrame As HTMLDocument
    2.  
    3. Private Sub browser_DownloadComplete()
    4. Set objFrame = browser.Document.frames(0).Document.Frame
    5. End Sub

    But when execute the line (Set objFrame = browser.Document.frames(0).Document.Frame)

    I got a runtime error saying Exception occurred.

    I also changed that line as :
    VB Code:
    1. Set objFrame = browser.Document.frames.Item(2).Document

    This time the error was : Object or class does not support the set of events

    Any idea to solve this problem or any idea to control the mouse click in a framed web page

    With regards,
    Nasreen
    Last edited by nasreen; Mar 4th, 2007 at 08:37 AM.

  12. #12
    Hyperactive Member
    Join Date
    Jun 2008
    Posts
    355

    Re: [RESOLVED] How control web component in VB6

    I know that this code has been around for a while but i find that it is the only thing that can somewhat take me towards what I need. If I could get some help I would really appreciate it...

    I am simply trying to read the page that can have x forms with x elements with x attributes and output that information into a textbox


    I know how to find elements with specific tag name but I don't know how to read out element names and ids regardless of tag name.

    I have used this code and it worked for "input" tagname

    Code:
    Dim inv As Integer
    Dim ind As Integer
    Dim c As Integer
    Dim FormName As Object
    Dim element As Object
    Dim tagName As String
    
    Text1 = ""
        
        inv = 0
        For Each FormName In MyBrowser.Document.getElementsByTagName("form")
            Text1 = Text1 & "Form Name: " & FormName.Name & vbCrLf & "Form ID: " & FormName.Id & vbCrLf & "Form Index: " & inv & vbCrLf
            inv = inv + 1
        Next FormName
        
        For ind = 0 To inv - 1
        Text1 = Text1 & vbCrLf & "- - - - - - -" & vbCrLf
        Text1 = Text1 & "Form index: " & ind & vbCrLf & vbCrLf
        
        
    
    
            Text1 = Text1 & "*********************************" & vbCrLf
        
        
            c = 0
            For Each element In MyBrowser.Document.Forms(ind).getElementsByTagName("input")
                    If element.Name = vbNullString Then
                        Text1 = Text1 & c & ":" & vbTab & "ID: " & element.Id & vbTab & " Type: " & element.Type & vbCrLf
                    Else
                        Text1 = Text1 & c & ":" & vbTab & "Name: " & element.Name & vbTab & " Type: " & element.Type & vbCrLf
                    End If
    
            c = c + 1
            Next element
            
            
            Text1 = Text1 & "- - - - - - -"
        Next
    How would I do this with all elements,, not just one tangname....

  13. #13
    Hyperactive Member
    Join Date
    Jun 2008
    Posts
    355

    Re: [RESOLVED] How control web component in VB6

    I used this to get form elements data when I click on them

    Code:
    If objDocument.activeElement.tagName = "INPUT" Then
        Text1.Text = "Name: " & vbTab & MyBrowser.Document.activeElement.Name & vbCrLf & _
                     "Id: " & vbTab & MyBrowser.Document.activeElement.Id & vbCrLf & _
                     "Type: " & vbTab & MyBrowser.Document.activeElement.Type
    ElseIf objDocument.activeElement.tagName = "A" Then
    Text1.Text = "link clicked."
    ElseIf objDocument.activeElement.tagName = "textarea" Then
    Text1.Text = "textarea."
    End If
    'Proceed with the submitting of the form
    objDocument_onclick = True
    How would I adapt this to loop through all forms and elements and just list them for me? I extracted that from your code above, and it helped me a bit,,,, I am sorry if I am asking dumb questions, I am not experienced with this stuff very much

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