This is a Regular Expression based world parser I made. This code is shorter than using case statements, gives you more information, and is always up to date.
Usage:
Code:
Notes:
Usage:
Code:
Private Sub Button1_Click()
Worlds.Update
Dim World As WorldData
World = Worlds.World(2)
Me.Text1.Text = World.Number
Me.Text2.Text = World.Players
Me.Text3.Text = World.Activity
End Sub
Notes:
- You will need to add the reference Microsoft VBScript Regular Expressions 5.5 to the project for this code to work.
- Place this code in a module named Worlds
Code:
Option Explicit
'' Fields
Private WorldArr() As WorldData
Private Init As Boolean
'' Constants
Private Const WorldsUrl = "http://www.runescape.com/slj.ws?lores.x=1&plugin=0&order=WMLP"
Private Const WorldsPattern = "\((\d+),(\d+),\d+,""([a-zA-Z0-9 \-]+)"",""([a-zA-Z0-9]+)"",(\d+),(\d+)\)"
'' Types
Public Type WorldData
Number As Integer
Players As Integer
Members As Boolean
Location As Integer
Prefix As String
Theme As String
Exists As Boolean
End Type
'' Methods
Public Sub Update()
Dim tInet As Object
Set tInet = CreateObject("InetCtls.Inet")
Dim Html As String
Html = tInet.OpenURL(WorldsUrl)
Dim X As New RegExp
X.Pattern = WorldsPattern
X.Global = True
Dim Matches As MatchCollection
Set Matches = X.Execute(Html)
ReDim WorldArr(1 To Matches.Count)
Dim Match As Match
Dim Count As Integer
Count = 1
For Each Match In Matches
Dim SM As SubMatches
Set SM = Match.SubMatches
Dim W As WorldData
With W
.Number = Val(SM.Item(0))
.Members = Val(SM.Item(1)) = 1
.Theme = SM.Item(2)
.Prefix = SM.Item(3)
.Players = Val(SM.Item(4))
.Location = Val(SM.Item(5))
.Exists = True
End With
WorldArr(Count) = W
Count = Count + 1
Next
Init = True
DoEvents
End Sub
Public Property Get World(WorldNo As Integer) As WorldData
Dim X As Integer
If Init = False Then Update
For X = LBound(WorldArr) To UBound(WorldArr)
Dim W As WorldData
W = WorldArr(X)
If W.Number = WorldNo Then
World = W
Exit Property
End If
Next
World.Exists = False
End Property
Public Property Get AllWorlds() As WorldData()
If Init = False Then Update
AllWorlds = WorldArr
End Property


