• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

help me parse this out (vb.net)

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

Crash893

"The man in black fled across the desert,
Joined
Mar 13, 2001
here is an example of what im trying to parse out

crash Rank: 304., 222 LL Tests completed, 17 factors found, P90 CPU: 506.253 LL + 7.967 fact. = 514.22 Years total

from this i want to remove 304(as rank) 222(as completed) and 514.22(as years)


Also some times the server goes down and ill get a message that looks like this


"crash not found in ranking list<br>
(account has not produced results or does not exist)"

What is a good way of testing for tis line
im not sure how to test it

If Me.txtretrive.Text = "crash not found in ranking list<br> (account has not produced results or does not exist)" Then Exit Sub
 
A simple solution i thought of could be this (Included are comments)....

'Split() function places all text separated by a " " (empty space) in an array element
Dim array() as string = me.textretrieve.text.split(" ")

'Check if it is an error message
If array(1) = "not" Then
Exit Sub
Else
Dim Rank As String = array(2).Substring(0, array(2).IndexOf(","))
Dim Complete As String = array(3)
Dim Years As String = array(18)
End If

This will give you the parsed information stored in the Rank, Complete, and Years variables. In the event that your server goes down and the error message is returned, this piece of code checks the array(1) element to see if it equals "not". This is assuming that the same error message is always displayed. If not, then you should be able to easily adapt the code to handle it.

Good Luck
 
Back