[Urgent] String Manipulation Help
Hi,
Im pretty new here and I need a hand splitting a string into parts to insert into a table (Data Grid View).
The string is as follows
Code:
map: mp_shipment
num score ping guid name lastmsg address qport rate
--- ----- ---- -------------------------------- --------------- ------- --------------------- ----- -----
0 0 7 719f826a9a7ee795ed3c43********** Not Yourself^7 0 127.0.0.1:28961 30793 25000
As you can see its for a game (Cod4) I am making a rcon tool. It is all going well apart from splitting the string.
What i need help with is putting the (num, GUID, Name and address) for each person (im showing only one) into a DGV.
Could anybody help me please.
Thank you
Adam
Re: [Urgent] String Manipulation Help
The following obtains column data by ordinal position. Three columns on the line must be numeric based on the line you provided and if this is not correct you need to correct it. In short this gives you a method to populate a unbound DataGridView.
Code:
Dim Lines = IO.File.ReadAllLines("Your file name goes here")
Dim MapNumber As Integer = 0
Dim Score As Integer = 0
Dim LastMsg As Integer = 0
For Each line In Lines
If Integer.TryParse(line.Substring(0, 3), MapNumber) AndAlso
Integer.TryParse(line.Substring(3, 6), Score) AndAlso
Integer.TryParse(line.Substring(64, 9), LastMsg) Then
DataGridView1.Rows.Add(New Object() _
{
MapNumber,
Score,
line.Substring(15, 32),
line.Substring(48, 14),
LastMsg,
line.Substring(75, 14)
}
)
End If
Next