Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 1st, 2006, 09:18 PM
Registered User
 
Join Date: Sep 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default HELP! Can anyone solve this problem?

Hi, I have googled & posted no success as yet. Can anyone help?

I have been wrestling with a problem for days. The solution is probably simple but i am not that experienced with html.
I have a vb program which sends info to a web page and as that page fills up a button is 'pressed' and the page is submitted, cleared and reloaded again.

To login to the site the code is as follows

oIE.Document.Forms("Login").All("district").Value = "district"
oIE.Document.Forms("Login").All("password").Value = password"
oIE.Document.Forms("Login").submit

then I navigate thru several pages via code to get where I need to go
then the code I use is basically this (with non essential info cut out)

N1 = "order.code"
N2 = "order.quantity"
While Not .EOF
    For x = 0 To 9
        If Not .EOF Then
            oIE.Document.Forms(0).All(N1 & x).Value = ![Product No]
            oIE.Document.Forms(0).All(N2 & x).Value = !Qty
        .MoveNext
        End If
        If Err = 3021 Then Exit For
    Next
     While oIE.Busy: Wend
    oIE.Document.Forms(0).submit

This works fine

So as you can see i am able to put info into forms where required. Now my problem. I have written new software that basically does the same thing but at a different site.
The login works fine but when the next page appears i am unable to enter any info into either of the 2 fields that are available

if i use the code
oIE.Document.Forms(0).All("Code").Value="1234" I get the error message
'Object variable or with block variable not set"
This is prolly because the forms(0) does not exist i think, although the form is there. I think i may need to access the document?

The html code is different for the input on this page also
On the first page the code reads
<input name="Password" type="password" id="Password" style="width:55px;" />

On the second page the code is;
<input id="SecurityCode" tabindex="1" name="SecurityCode" type="TEXT" value="" size="16" maxlength="6" />

so i do not know if there is a different way to pass a value to the "Input ID" field as opposed to the INPUT NAME field.

ANY help would be greatly appreciated as would some direction as to find out more about navigating or manipulating web pages from within VB. (events properties methods etc)

Many thanks in advance

EDIT
I have also noticed that the form name is missing and this is following the head
</head>
<link rel="stylesheet" type="text/css" HREF="/CMSIncludes/css/csall.css" title="def"/>

<body onload="document.frmSingleShare.SecurityCode.focus ();">
<SCRIPT LANGUAGE="JavaScript1.2" SRC="/CMSIncludes/menu/HM_LoaderX.js" TYPE='text/javascript'></SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.2" SRC="/CMSIncludes/menu/cfg/SHARES01.js" TYPE='text/javascript'></SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.2" SRC="/CMSIncludes/menu/HM_LoaderXa.js" TYPE="text/javascript"></SCRIPT>

is it possible that this is a child window of sorts and that is why i cannot use the forms(0) methods
Reply With Quote
  #2 (permalink)  
Old September 4th, 2006, 03:52 PM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

A suggestion: Choose subject lines that give an idea of the type of question.

One of the things I would do—just to verify—is put up a message box with the contents oIE.Document.Forms(0).name. If that generates the same error, then you are probably right that the form doesn't exist in the context you are looking for it in.

When you say “I have also noticed that the form name is missing . . . ,” given the HTML you then present it looks more as if the form [u]element</u> is what is missing. Of course, if that is so, there will be no form to reference in “oIE.Document.Forms.”

When you say “is it possible that this is a child window of sorts,” your meaning is unclear (to me). Given the text I've made red, what does “this refer to?” You've given no antecedent. Do you mean “the web page that holds the running code?” The “child window”: maybe. Could you expand that thought some? (I'm thinking that your asking the question implies a suspicion you harbor, and it could be helpful to hear your thoughts on that.)
Reply With Quote
  #3 (permalink)  
Old September 4th, 2006, 10:57 PM
Registered User
 
Join Date: Sep 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Many thx for your reply brian

Any expansion on document.forms(0). does generate an error. i have tried byelementid and that does not work either.
By "child Window" i am thinking that maybe the next window is loaded by the previous form and so loses it's focus. Sorry I cannot be more specific but i am reasonably new to this type of coding.
I have tried to access the window by the following code

Dim html as htmldocument
set html = webrowser1.document
HTML.All.item("LoginName").Value="login"
...
etc

which gives me exactly the same results. The page loads in the browser ok but i am just unable to access it via code. I can manually type the info in that i need to but that is defeating the purpose

I could send you the source of the offending page if you think u may be able to help.

Thanks again
Joe


Reply With Quote
  #4 (permalink)  
Old September 5th, 2006, 09:56 AM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

I think you are on the right track regarding whether there even is a form to reference. If there is no <form . . . > </form> tag set, then you have no form to reference.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help to solve problem PankajMishra XSLT 7 April 19th, 2007 08:27 AM
Will you please help me to solve this problem....? vis_kapadia Excel VBA 2 November 22nd, 2006 04:57 AM
Solve the problem chandan_tandon General .NET 0 October 4th, 2006 07:00 AM
Solve my problem first? wakil C# 3 February 9th, 2006 08:21 AM
could you solve my problem? Robin1 Javascript 0 September 13th, 2004 10:13 PM



All times are GMT -4. The time now is 03:09 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.