VB and HTML

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Joe
    New Member
    • Aug 2006
    • 2

    #1

    VB and HTML

    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.Fo rms("Login").Al l("district").V alue = "district"
    oIE.Document.Fo rms("Login").Al l("password").V alue = password"
    oIE.Document.Fo rms("Login").su bmit

    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.Fo rms(0).All(N1 & x).Value = ![Product No]
    oIE.Document.Fo rms(0).All(N2 & x).Value = !Qty
    .MoveNext
    End If
    If Err = 3021 Then Exit For
    Next
    While oIE.Busy: Wend
    oIE.Document.Fo rms(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.Fo rms(0).All("Cod e").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:55 px;" />

    On the second page the code is;
    <input id="SecurityCod e" tabindex="1" name="SecurityC ode" 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
  • Tomy
    New Member
    • Sep 2006
    • 1

    #2
    Hi!

    A few weeks ago i got the same problem when i needed to submit data to a webpage (GET request to download a file from server). So basicaly you dont need the code you wrote, you just need to comunicate with apache web server, i know it sounds quite "heavy" but its not so hard as it seems. Try google.com, it helped me :)

    You need to send some header stuff. Here's a sample of how to get the index page from a server:
    GET / HTTP/1.0
    Host: microsoft.com
    Content-Type: application/x-www-form-urlencoded

    And Server's answer:

    HTTP/1.1 302 Object moved
    Connection: close
    Date: Fri, 08 Sep 2006 20:36:41 GMT
    Server: Microsoft-IIS/6.0
    Level: T3
    X-Powered-By: ASP.NET
    Location: http://www.microsoft.c om
    Content-Length: 145
    Content-Type: text/html
    Set-Cookie: ASPSESSIONIDQAC QBDBS=LFODKIDAN LDBIJNJLAKBHBGB ; path=/
    Cache-control: private

    + Basic HTML

    So basically, the web server telled us that we need to redirect to www.microsoft.c om. The "Location: http://www.microsoft.c om" tells us to do it.


    In fact is much much simplier - you just send your data(username=b lah-blah&password=s ss) to a webpage through winsock and the server responds to your query e.g. "200 OK" and some header stuff. There's no need for running trough the code you wrote, just tell the webserver what to do and he will do it :)

    I know i explained very bad and my language was just awfull, but im not american im Latvian, so forgive me for any mistakes i have made :)

    Comment

    Working...