Results 1 to 7 of 7

Thread: Quick question about strings

  1. #1

    Thread Starter
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871

    Quick question about strings

    Hi everybody. I'm having a stupid little problem with retrieving strings from a collection. I'm using the Web Browser Control and I'm trying to get all 'formatBlocks' (Heading 1, Heading 2, etc.).

    I have working code for this from MSDN, in JavaScript. In a webpage it works like a charm, but when I convert it to VB I only get an empty string in return from the collection.

    Check out the web example (IE only). Why, then, doesn't this work in VB?
    VB Code:
    1. For i = 1 To objHelper.BlockFormats.Count
    2.     MsgBox objHelper.BlockFormats.Item(i)
    3. Next i
    It probably just has to do with some string parsing, creating a buffer or something... The Count method returns the same value as in the web example, so I know the collection is correct. Can anyone shine some light on this?
    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:

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Quick question about strings

    I get "16" then an error messagebox saying missing fields.

  3. #3

    Thread Starter
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871

    Re: Quick question about strings

    With the web example? That's odd. The 16 box is correct, that's the number of format blocks on IE6. But the next messagebox should hold the names of all blocks, in my case (Dutch): Normaal Met opmaak Adres Kop 1 Kop 2 Kop 3 Kop 4 Kop 5 Kop 6 Genummerde lijst Lijst met opsommingstekens Inhoud Menulijst Definitieterm Definitie.

    But, anyway, can you think of any reason why a string would appear in a page but not from within VB?
    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:

  4. #4
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Quick question about strings

    G'Day Vadar,

    1. Your IE example worked OK for me.


    2. Possibly the MessageBox is full of preceeding characters and the message dosn't fit the MessageBox.
    Does this help:

    VB Code:
    1. MsgBox Replace(objHelper.BlockFormats.Item(i), Chr(0), "")
    2. 'Or
    3.     MsgBox Trim$(objHelper.BlockFormats.Item(i))


    Edit: The above assumption generaly relates to a large MessageBox... with noting in it.
    If in your case if it's small (ie. would hold one line only), then the problem may be elsewhere.

    Bruce.
    Last edited by Bruce Fox; Apr 19th, 2005 at 04:30 PM.

  5. #5

    Thread Starter
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871

    Re: Quick question about strings

    Thanks for your idea, Bruce. The messagebox is small and removing the Chr(0)'s or trimming it didn't help. The Len and LenB function both return 0 on the string.
    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:

  6. #6
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Quick question about strings

    Do you need to return .Value or .Text?




    Bruce.

  7. #7

    Thread Starter
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871

    Re: Quick question about strings

    According to this page just item would do.
    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:

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