Can someone help me write some code to add to my simple web browser?
Upon reaching the designated site, the code needs to tab to each form input window and populate it with text (which is pre-stored as variables).
I can get the text data pre-stored and navigate to the site, but what code do I need to "tab" "print" "tab" "print" "tab" "print" ... to fill the form?
The help I received from this forum put me on the right track. it took only a couple of days form to make great progress on my project. However, why is Microsoft sabotaging me every step of the way?
Have I been away from VB so long that I'm missing stuff thats come along in the past few years? I downloaded and installed the VB service pack 6 but I'm still having problems.
My program it works but when I close VB and reload, microsoft kills it in action. The dialog box pops up ....... "Visual Basic has encountered a problem and needs to close. We are sorry for the inconvenience .. blah blah blah ..."
Then its ask me to send the report created by pressing the button. No matter if I choose send or don't send, VB folds up and I have rewrite portions of the program again.
OK , at the thought of posting all that code I was about to faint so I sought to boil it down to the essentials, and lo ! I can't even reload the basic browser without it crashing.
I think I may have trouble naming the project, group and form.
With one form with WebBrowser1 placed in the center and the start up code :
Private Sub Form_Load()
WebBrowser1.Navigate "http://www.mapquest.com"
End Sub
When I run this it works. Then I save it, close out VB and try to reload and BANG, it crashes!
The help I received from this forum put me on the right track. it took only a couple of days form to make great progress on my project. However, why is Microsoft sabotaging me every step of the way?
Have I been away from VB so long that I'm missing stuff thats come along in the past few years? I downloaded and installed the VB service pack 6 but I'm still having problems.
My program it works but when I close VB and reload, microsoft kills it in action. The dialog box pops up ....... "Visual Basic has encountered a problem and needs to close. We are sorry for the inconvenience .. blah blah blah ..."
Then its ask me to send the report created by pressing the button. No matter if I choose send or don't send, VB folds up and I have rewrite portions of the program again.
What the heck is going on?
Dont' know why but I suggest reinstalling VB.
BTW make it a habit to save ur work before running. That saves a lot of work in unfortunate conditions.
Pradeep, Microsoft MVP (Visual Basic) Please appreciate posts that have helped you by clicking icon on the left of the post.
"A problem well stated is a problem half solved." — Charles F. Kettering
Well now I've tried the above ... removed SP6, re-created the basic other half of project without the browser, saved it ..no problem.
Its that darned browser control thats killing me... and I'm closed to DEAD too ! I would probably feel better if I could just get my hands around Gates' neck.
Isn't it correct to use the "MS Internet Controls" under "Project, Components"? It works, it even compiles and the exe works. But the stupid VB won't let me reload if I include the browser.
there is a fix for this but i can't remember what it was, it is something to do with the url but i don't remember now, i know you can open the form in notepad, do a small edit then it is fixed.
i will try to dream about it for you, if i do i will post again in the morning
also try searchs in the forum, cos i think it was on here before
pete
i think
if you open the form.frm in notepad and edit the line
Location = "http:///"
to as above, it will fix your problem you may have to do it each time, if you do it a lot it would be easy to write a program to fix it each time.
Last edited by westconn1; May 29th, 2005 at 12:15 PM.
i am glad i got it right, i really wasn't sure. i can't remember what causes it in the first place, i think we might have figured it out, but once it starts to do it it seems to stay with you.
i think, you can actually write code in the form to edit itself would you believe as once the form is loaded it is not open, until you save it.
My project has been coming along very well until I encountered another potential killer today.
The site which hosts the forms I need to fill has a split format. At the top of the page there is a header which holds the page address window. The lower 4/5ths of the page has the input boxes. This portion of the page has its on scroll bar which allows the header (with it submit button) to remain visible. My program won't fill the inputs since “I think” the header portion (which “owns” the page address) seems to be unaware there that the sub-page has inputs. The header seems to only know how to submit the subpage. HOWEVER, a simple right-click on sub-page, view its properties reveal the sub-pages' address. Then a run of the program directed at the subpage address works fine. No header, just the form portion where I can fill all inputs nice and clean.
The problem is, how do I submit the page? I think I have to find a way to make the form-filler leap over the header and find the sub-page inputs. Otherwise, without the header page addressed, I won't be able to submit. And even if I did find a way, I believe the “submit” button may carry my ”legitimate” session id. So If I create my on stand-alone ”submit” button I'll have to figure out how to embed credentials within.
Could my imagination be running away? somebody please calm my fears!
Take a look at the Document Object Model (DOM). The "subpage", as you call it, actually sounds like a frame - you should be able to either load that frame direct or access it's components by "document.frames(x)". There's some pretty good code on the DOM floating around the forum (link I was gonna post here is now busted..sorry)
Ok, so it is a "frame" within the page that I have to figure out how to direct my "filler" program. I haven't looked at the zip file yet, will have to get home later today for that. But you are saying "all is not lost", my job can be done ?
You might consider loading the Firefox browser. If you load the diagnostic tools or whatever they call it, it gives you their "DOM" inspector. This is a great tool for inspecting the DOM structure and finding where the various elements you are trying to address or populate are located.
As far as I know you cannot add the Firefox browser into a VB program, you are stuck with WebBrowser. Firefox just gives you a chance to visually decipher the DOM structure and to find the elements you ar looking for.
In Firefox, you will see a listing of the DOM objects, many of which are collections of various element types. Within your program, create the subroutine:
Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
end sub
Within this subroutine, you have the HTML document in pdisp.document. By playing with the various elements and collections you can see visually in Firefox, you can test your code to dig down into the collections aqnd find what you need to interact with. To me the DOM is extremely confusing and poorly designed, but eventually you can find what you need.
Search the forums for DOM, for examples of using the collections and referencing elements
Folks I appreciate all the good help and love being passed around here but I'm just not getting the DOM deal. Perhaps if I could spend a little more time studying up I might catch up. However, that article by theVader: "Using the DHTML Document Object Model" is just a little too much for me right now.
I'm wondering if someone might illustrate a solution to my project if I post a link to a similar, simpler site?
If I could just see what needs to be done I think I could adapt the technique for my project. I cannot post the actual site because it is inhouse only.
Find a valid item number on EBAY and plug it in. I don't know if the one here is still available. It should show you what DOM can accomplish. This was done mostly by TheVader when someone asked.
Last edited by dglienna; Jan 29th, 2006 at 05:29 PM.
The Image Parser is an interesting learning tool but I haven't seen how it can help with my task yet.
My task seems simple to me but I don't understand the specific use of "tags" or object identifying to make the form filler populate the frame.
As I said before, if I direct the browser to the form address the program works ok. But I need to load the page with the header frame in order to push the "submit" button and navigate to other pages.
My question is what does my code need to overlook the header addressing and jump down to the frame before populating?