|
-
Apr 19th, 2005, 03:22 PM
#1
Thread Starter
Fanatic Member
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:
For i = 1 To objHelper.BlockFormats.Count
MsgBox objHelper.BlockFormats.Item(i)
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
-
Apr 19th, 2005, 03:27 PM
#2
Re: Quick question about strings
I get "16" then an error messagebox saying missing fields.
-
Apr 19th, 2005, 04:10 PM
#3
Thread Starter
Fanatic Member
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
-
Apr 19th, 2005, 04:27 PM
#4
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:
MsgBox Replace(objHelper.BlockFormats.Item(i), Chr(0), "")
'Or
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.
-
Apr 19th, 2005, 04:35 PM
#5
Thread Starter
Fanatic Member
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
-
Apr 19th, 2005, 04:41 PM
#6
Re: Quick question about strings
Do you need to return .Value or .Text?
Bruce.
-
Apr 19th, 2005, 05:49 PM
#7
Thread Starter
Fanatic Member
Re: Quick question about strings
According to this page just item would do.
Author for Visual Basic Web Magazine
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|