View Full Version : VB, Collecting data from a string

07-30-2007, 06:09 PM
Hey guys, my deal is that I have a code sort of like this (html)

<div id=contactlist>John1</div>
<div id=contactlist>John2</div>
<div id=contactlist>John3</div>
<div id=contactlist>John4</div>
<div id=contactlist>John5</div>
<div id=contactlist>John6</div>

and I put that into a string in Visual Basic, What I want to do is search in that string all the Johns and add them to a listbox, but only the names, not that <div id=. . . or the </div> part.

Please help!!

Thank You!

07-30-2007, 06:36 PM
Using the code from this support article - http://support.microsoft.com/kb/818802 - as an example and using the pattern ">john.*<" should get you a collection of all the "john" matches.

Here's a resource for creating regular expressions in VB - http://www.aivosto.com/vbtips/regex.html


08-02-2007, 05:28 AM
Option Explicit
Dim myFile,objFSO,objFile,line,found
Set objFSO=CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(myFile,1)
Do Until objFile.AtEndOfStream
If InStr(1,line,"john",vbTextCompare) > 0 Then
found=Replace(line,"<div id=contactlist>","")
WScript.Echo "Found a john at" , line
End If

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum