Problem with my coding here its not hard help would be appreciated

{IP}Gil-Galad

Member
Joined
Sep 25, 2005
Messages
19
Programming Experience
Beginner
[Resolved] Problem with my coding here its not hard help would be appreciated

VB.NET:
[SIZE=1][COLOR=#0000ff]Private[/COLOR] [COLOR=#0000ff]Sub[/COLOR] btnArmor_Click([COLOR=#0000ff]ByVal[/COLOR] sender [COLOR=#0000ff]As[/COLOR] System.Object, [COLOR=#0000ff]ByVal[/COLOR] e [COLOR=#0000ff]As[/COLOR] System.EventArgs) [COLOR=#0000ff]Handles[/COLOR] btnArmor.Click[/SIZE]
[SIZE=1][COLOR=#0000ff]With[/COLOR] OpenFileDialog1[/SIZE]
[SIZE=1].Filter = "All Files (*.*)|*.*|" & _[/SIZE]
[SIZE=1]"INI Files (*.ini)|*.ini"[/SIZE]
[SIZE=1].FilterIndex = 1[/SIZE]
[SIZE=1].Title = "Open Armor.ini"[/SIZE]
[SIZE=1].CheckFileExists() = [COLOR=#0000ff]True
[/COLOR][/SIZE][SIZE=1].CheckPathExists = [COLOR=#0000ff]True
[/COLOR][/SIZE][SIZE=1].ValidateNames = [COLOR=#0000ff]True
[/COLOR][/SIZE][SIZE=1].DereferenceLinks = [COLOR=#0000ff]True
[/COLOR][/SIZE][SIZE=1].InitialDirectory = "C:\Documents and Settings\Owner\Desktop\BIG\DATA\ini"[/SIZE]
[SIZE=1].ShowDialog([COLOR=#0000ff]Me[/COLOR])[/SIZE]
[SIZE=1][COLOR=#0000ff]Dim[/COLOR] sr [COLOR=#0000ff]As[/COLOR] IO.StreamReader = IO.File.OpenText(.FileName)[/SIZE]
[SIZE=1][COLOR=#0000ff]Dim[/COLOR] Line [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]String
[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]Do[/COLOR] [COLOR=#0000ff]Until[/COLOR] Line = ""[/SIZE]
[SIZE=1]Line = sr.ReadLine[/SIZE]
[SIZE=1][COLOR=#0000ff]If[/COLOR] Line = "Armor " [COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=1]lstArmor.Items.Add(Line) [COLOR=#008000]'.Substring(6))
[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]If
[/COLOR][/SIZE][COLOR=#0000ff][SIZE=1]Loop[/SIZE]
[/COLOR][SIZE=1]sr.Close()[/SIZE]
[SIZE=1][COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]With
[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]Sub[/COLOR][/SIZE]
Well you open a file and it reads through the whole thing until it comes with a line that begins with "Armor " and once its found it stores it in a list box.
Obviously what im doing is the wrong way any pointers?
 
Last edited by a moderator:
You need to change the line that says:
VB.NET:
If Line = "Armor " Then
to
VB.NET:
If Line.StartsWith("Armor ") Then
 
Back
Top