Go Back   CodingForums.com > :: Computing & Sciences > Computer Programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-30-2007, 05:09 PM   PM User | #1
seetherage
New Coder

 
Join Date: Dec 2003
Location: USA
Posts: 11
Thanks: 1
Thanked 1 Time in 1 Post
seetherage is an unknown quantity at this point
VB, Collecting data from a string

Hey guys, my deal is that I have a code sort of like this (html)

PHP Code:
<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!
seetherage is offline   Reply With Quote
Old 07-30-2007, 05:36 PM   PM User | #2
TheShaner
Senior Coder

 
TheShaner's Avatar
 
Join Date: Sep 2005
Location: Orlando, FL
Posts: 1,125
Thanks: 2
Thanked 40 Times in 40 Posts
TheShaner will become famous soon enoughTheShaner will become famous soon enough
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

-Shane
TheShaner is offline   Reply With Quote
Old 08-02-2007, 04:28 AM   PM User | #3
ghostdog74
New Coder

 
Join Date: May 2006
Posts: 39
Thanks: 0
Thanked 1 Time in 1 Post
ghostdog74 is an unknown quantity at this point
Code:
Option Explicit
Dim myFile,objFSO,objFile,line,found
myFile="C:\myfile.txt"
Set objFSO=CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(myFile,1)
Do Until objFile.AtEndOfStream
	line=objFile.ReadLine
	If InStr(1,line,"john",vbTextCompare) > 0 Then
		found=Replace(line,"<div id=contactlist>","")
		found=Replace(line,"</div>","")
		WScript.Echo "Found a john at" , line
	End If 
Loop
ghostdog74 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:30 AM.


Advertisement
Log in to turn off these ads.