Reading a text file locating certain positions, I am using:
The problem is reading txtStreetNumber.Text = line.Substring(102, 5). If the number is a four digit one such as 3226, 32260 is what is extracted. What needs to be done to correct?
Thank you.
Code:
Dim Lines = _
( _
From line In IO.File.ReadAllLines(OpenFD.FileName) _
Where line.Length > 0 AndAlso _
Not line.StartsWith("5") AndAlso _
Not line.StartsWith("9") _
).ToList 'excludes lines starting with 5 or 9
'next certain positions are read
For Each line In Lines
txtAccountNumber.Text = line.Substring(21, 4)
txtLastName.Text = line.Substring(72, 15)
txtFirstName.Text = line.Substring(87, 15)
txtStreetNumber.Text = line.Substring(102, 5)
txtStreetNumber.Text = Replace(LTrim(Replace(txtStreetNumber.Text, "0", " ")), " ", "0")
txtAddress.Text = line.Substring(107, 20)
txtCity.Text = line.Substring(132, 15)
txtState.Text = line.Substring(147, 2)
txtZip.Text = line.Substring(149, 5)
mskPhone.Text = line.Substring(154, 10)
Next
'the info is then saved.
The problem is reading txtStreetNumber.Text = line.Substring(102, 5). If the number is a four digit one such as 3226, 32260 is what is extracted. What needs to be done to correct?
Thank you.