VB tag remover!

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

VB tag remover!

Post by Joe »

This is a silly place to ask this but I seem to get help with whatever language I choose in these forums so I will give it a try.

I am looking for a quick snippet writtin in Visual Basic 6.0 that returns the string which is in between the <title> tag. For example if my form had something like <title>My Form</title> the program would result with "My Form".

Any help appreciated.

Regards


Joe 8)


*EDIT BY Joe* I think the code would be better using timers as loops seem to be unreliable with large amounts of code.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

why do you want it in VB?
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

Well I am doing a little project for college and VB was my choice of language.
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

you'll never win a 'VB is a good coding langauge' with feyd, so dont even try.

hahaha

8)
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

lol ok well it was worth a try :D
sell-traffic
Forum Commoner
Posts: 26
Joined: Thu Aug 05, 2004 9:35 pm

Post by sell-traffic »

Yes, ignore the "VB is bad comments," I understand the argument, but it's still great for rapid development in my opinion. You would have to load the source into VB with a Inet Control. Then Instr() it for everything between <Title> and </Title>.

Good luck,

Josh
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

Yeah thanks however, I require no controls, instead I use winsock in order to achieve the source from websites. :D
AngusL
Forum Contributor
Posts: 155
Joined: Fri Aug 20, 2004 4:28 am
Location: Falkirk, Scotland

Post by AngusL »

Code: Select all

'Load source

Source = Cstr(Left(Source,  8))
Source = Cstr(Right(Source, 8))
Should do it.
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

that would only work, if and only if <title>whatever</title> as the only thing in the source, and even then if it was something else it would be wrong. instead try this:

Code: Select all

tmp = Right(txtSource, Len(txtSource) - (InStr(LCase(txtSource), "<title>") + 6))
txtTitle = Left(tmp, InStr(LCase(tmp), "</title>") - 1)
Post Reply