Results 1 to 4 of 4

Thread: Changing/Replacing HTML-Code

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2000
    Location
    Vienna, Austria
    Posts
    62
    I need some help for the following problem:
    How can I change/add a certain content(i.e. Name of customer) in an existing HTML document via VB?
    For example:

    Dear ******** <--- Name of customer to be changed/added
    We want to inform.......

    The HTML files are pure HTML without META-Tags, without Java/Javascript.
    Any input would be great.


  2. #2
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Well having done vaguely this kind of thing before, I'd suggest that you find a recognisable point in your HTML file which you can use as a reference point to the place you have to insert your text. So, in this case, it might be the first instance of the string "Dear ". I'll assume this is the case from here, but if it's not you can figure something out I'm sure.

    First read the whole file into a big string variable. Then you can use code that's something like this:

    Code:
    strHTML = Left(strHTML, InStr(strHTML, "Dear ")) & _
              strCustomerName & _
              Right(strHTML, Len(strHTML) - InStr(strHTML, "Dear ") + 1)
    
    'now output strHTML to your customised HTML file.
    That code has a lot of room for optimization if you're going to be doing this a lot.
    Harry.

    "From one thing, know ten thousand things."

  3. #3
    Addicted Member darrenl's Avatar
    Join Date
    Jul 2000
    Location
    Portsmouth, UK
    Posts
    148
    How are you accessing the HTML from VB? <font color="#00007F">If</font> vb is a viewer then before you .Navigate to the browser you could read in the file (line input) and replace a custom tag.

    [code]
    open "C:\inetpub\test.html" for input as #1
    do
    line input #1,a$
    if instr(a$,"<@NameTag>") then
    a$=left$(a$,instr(a$,"<@NameTag>")-1) & strCustomerName & right$(instr(a$,"<@NameTag>")+10)
    while not eof(1)
    close #1
    [\code]

    if this helps......
    Dazzer

  4. #4

    Thread Starter
    Member
    Join Date
    Nov 2000
    Location
    Vienna, Austria
    Posts
    62

    :-)

    Thanks a lot. This will do it.
    Life is trip, eat it and smile.

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