PDA

View Full Version : Why is my variable not printing to my list?



jojo
03-19-2012, 10:23 PM
I use the same format for other tasks just like this in my script, but for some reason, this one is not adding my strEmail to my list, any suggestions? Thank you in advance! :)

My Code:

Dim strEmail As String
strHTML = wrapper.Request("GET", "[Only registered and activated users can see links]", "[Only registered and activated users can see links]")
strEmail = GetStringBetween(strHTML, "size=""""30"""" maxlength=""""60"""">", "</td>")
List1.AddItem ("Email: " + strEmail)



Page Source

[Only registered and activated users can see links]

Joshsadf
03-19-2012, 10:28 PM
List1.additem "Email: " & strEmail

jojo
03-19-2012, 10:35 PM
Thanks, but it still does not show the email :/

Joshsadf
03-19-2012, 10:39 PM
Ok then something is wrong with your GSB.

Use.

strEmail = GetStringBetween(strHTML, "60" & Chr(34) & ">", "")

Zachafer
03-19-2012, 10:49 PM
Debug.Print "size=""""30"""" maxlength=""""60"""">"

Output: size=""30"" maxlength=""60"">

Try this:


Dim strEmail As String
strHTML = wrapper.Request("GET", "[Only registered and activated users can see links]", "[Only registered and activated users can see links]")
strEmail = GetStringBetween(strHTML, "size=""30"" maxlength=""60"">", "</td>")
List1.AddItem ("Email: " & strEmail)

It is ok to use "+" for string concatenation ([Only registered and activated users can see links]_of_sets_of_strings) but in visual basic we use "&" (or some of us use Mid$ ;))

The & operator is recommended for string concatenation because it is defined exclusively for strings and reduces your chances of generating an unintended conversion.

Hexx
03-20-2012, 05:26 AM
(or some of us use Mid$ ;))


Why/how would you use Mid$ for concatenation?

Soredavide
03-20-2012, 05:39 AM
Take out the quotes


strHTML = Replace(strHTML, """", "")


Source will be


[Only registered and activated users can see links]


Then use


strEmail = GetStringBetween(strHTML, "maxlength=60>", "</td>")
List1.additem "Email: " & strEmail

Zachafer
03-20-2012, 09:33 AM
Why/how would you use Mid$ for concatenation?

Why: Faster, especially when there are a lot of concatenations.

How: [Only registered and activated users can see links]
[Only registered and activated users can see links]

Reemer
03-20-2012, 09:42 AM
Take out the quotes


strHTML = Replace(strHTML, """", "")


Source will be


[Only registered and activated users can see links]


Then use


strEmail = GetStringBetween(strHTML, "maxlength=60>", "</td>")
List1.additem "Email: " & strEmail


Damn why did I never think of just removing the quotes -_-
Thanks man, you probably just saved me lots of time :P

Hexx
03-20-2012, 09:54 AM
Why: Faster, especially when there are a lot of concatenations.

How: [Only registered and activated users can see links]
[Only registered and activated users can see links]

how often do you have to actually concatenate strings of 50kb or more though? :P i can't think of one situation where I've ever had to do that.