Hello, this is one way you can read the data from the file!
For sMaterial send "[Bronze]" or "[Iron]" and for sItem "[Item name]" ex: "[Plate Legs]"
This function is case sensitive. But to fix that add some UCase()Code:Public Sub GetData(sMaterial As String, sItem As String) Dim sTemp As String Dim iDP As Integer, iCost As Integer Dim bGotIt As Boolean 'Has i gathered the info? Open "c:\data.ini" For Input As #1 Do While Not EOF(1) Input #1, sTemp If InStr(1, sTemp, sMaterial) Then Do While Not EOF(1) Input #1, sTemp If InStr(1, sTemp, sItem) Then Input #1, sTemp '"DefensePoints=" = 14 char's so skip 14! iDP = CInt(Mid(sTemp, 15, Len(sTemp) - 14)) Input #1, sTemp '"Cost=" = 5 char's so skip 5! iCost = CInt(Mid(sTemp, 6, Len(sTemp) - 5)) bGotIt = True Exit Do End If Loop End If Loop Close #1 MsgBox sMaterial & vbCrLf & sItem & ":" & "DP: " & iDP & vbCrLf & "Cost: " & iCost End Sub




Reply With Quote