'What labels to look for in the overview scan Dim strInfoArray() As String = {"Score:", "Metal:", "Mineral:", "Food:", _ "Unused Land", "Farm Land", "Metal Mining", _ "Mineral Mining"} 'Parameters: strScan The scan input by the user ' intIndex The index position in the scan to start getting the value from 'Returns: Long The value that was extracted from the scan at the given position. ' 'This function will get the value from the scan at the starting position given by intIndex. From the starting 'index position it will check each character in the string and put it into another string until a space 'or dash is found which indicates the end of the value. Any commas are then removed and the resulting string 'is converted into a long integer and returned back from the function. Private Function GetValue(ByVal strScan As String, ByVal intIndex As Integer) As Long 'A string to hold the value being extracted Dim strValue As String 'A character extracted from the scan Dim strCharacter As String 'True if function should stop extracting characters Dim blnStop As Boolean Try 'Loop while the index position is less than the length of the scan and blnStop is still False Do While intIndex < strScan.Length And blnStop <> True 'Extract 1 character from the string at the given index position strCharacter = strScan.Substring(intIndex, 1) If strCharacter <> " " And strCharacter <> "-" Then 'The character extracted from scan is not a space or dash so must 'be part of the number to add it to the strValue string strValue &= strCharacter Else 'Extracted a space or a dash so set blnStop to True to stop extracting blnStop = True End If 'Move the index position to the next position in the scan intIndex += 1 Loop If strValue <> "" Then 'String is not empty so must have a valid value in the string 'so remove any commas and then convert it into a long integer strValue = strValue.Replace(",", "") Return (Convert.ToInt64(strValue)) Else 'String was empty so return 0 Return 0 End If Catch ex As Exception MessageBox.Show(ex.Message) End Try End Function Try 'Remove any unwanted strings from the scan text strScan = strScan.Replace(strSAT_MK_II_LABEL, strNEW_SAT_MK_II_LABEL) strScan = strScan.Replace(vbCrLf, "-"c) strScan = strScan.Replace(vbTab, "-"c) strScan = strScan.Replace(" -", " ") strScan = strScan.Replace(STRDYRAD_LABEL, strDRYAD_LABEL) strScan = strScan.Replace(strDONATEDMONEY, "") strScan = strScan.Replace(strDONATEDMOREMONEY, "") strScan = strScan.Replace(STRDONATESEACHMONTH, "") 'Get the line which contains the playername, coords and alliance strLine = GetPlayerName(strScan) 'Extract the player name, coords and alliance into 3 separate variables Call GetPlayerAllianceNameCoords(strLine, strCoords, strPlayerName, strAlliance) 'Work out the position in the scan string where creature and defences start intCreatureStartPos = strScan.IndexOf(strMINERALMINING) 'Work out the position in the scan string where creature and defences end intCreaturesEndPos = strScan.IndexOf(strALLIANCEAGENDA) 'Work out the position in the scan string where auctions start intAuctionsStartPos = strScan.IndexOf(strAUCTION) If intAuctionsStartPos = -1 Then intAuctionsStartPos = 100000 End If 'Get the tick the overview page was sent from the scan string intIndex = strScan.IndexOf(strTICK) intTick = Convert.ToInt32(GetValue(strScan, intIndex + strTICK.Length + 1)) 'Check if the player name was found If strPlayerName <> "" Then 'Check if the player exists If CheckMemberExists(strPlayerName) = False Then 'Player doesn't exist so put information into the data row dtrNewMemberInfo("PlayerName") = strPlayerName dtrNewMemberInfo("Type") = "Ally" dtrNewMemberInfo("Alliance") = strAlliance dtrNewMemberInfo("Coords") = strCoords dtrNewMemberInfo("Tick") = intTick dtrNewMemberInfo("Score") = 0 dtrNewMemberInfo("Metal") = 0 dtrNewMemberInfo("Mineral") = 0 dtrNewMemberInfo("Food") = 0 dtrNewMemberInfo("LandUnused") = 0 dtrNewMemberInfo("LandFood") = 0 dtrNewMemberInfo("LandMetal") = 0 dtrNewMemberInfo("LandMineral") = 0 dtrNewMemberInfo("NanoTech") = True dtrNewMemberInfo("MP") = False dtrNewMemberInfo("EnhancedMP") = False dtrNewMemberInfo("SpaceElevator") = False 'Add the new data row to the database with the new information dtrNewMemberInfo.EndEdit() DsMemberInfo1.Tables("player").Rows.Add(dtrNewMemberInfo) daMemberInfo.Update(DsMemberInfo1) DsMemberInfo1.AcceptChanges() End If 'Get the player's ID which is automatically generated by the database intPlayerID = GetMemberID(strPlayerName) 'Get all the player's information back from the database daMemberInfo.SelectCommand.CommandText = "select * from player where id = " & intPlayerID DsMemberInfo1.Clear() daMemberInfo.Fill(DsMemberInfo1, "player") DsMemberInfo1.Tables("Player").Rows(0).Item("tick") = intTick 'Go through each item in the strInfoItemArray and extract out the values for 'each item from the scan For Each strInfoItem In strInfoArray intIndex = strScan.IndexOf(strInfoItem) If intIndex >= 0 Then 'Found the item in the scan so extract the corresponding value intValue = GetValue(strScan, intIndex + strInfoItem.Length + 1) 'Get the corresponding database field name for the item and update the value 'extracted to the database strFieldName = GetFieldName(strInfoItem) DsMemberInfo1.Tables("Player").Rows(0).Item(strFieldName) = intValue End If Next