Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27355

Please HELP I have aged in a week trying to figure this out have no slept in 36 hours

$
0
0
I have a data file and i would like to search it for the matching zip code entered onto my form and auto fill in the city and state form the same line as the zip code. I can match the zip code but I cannot match the entire line. My I have Zip, City, State, County in my array. if I type 10005 into my form I get new York NY; but if I type 38116 into my form I get new York NY when the city and state should be Memphis, TN. I have tried several things so my code is really messy. can anyone please help!

Imports System.IO

Public Class Personal_Information

Dim Zips(38854) As String
Dim currentline As Integer
Dim Ziprecord(4) As String



Private Sub txtZip_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtZip.TextChanged

'Dim sr As StreamReader
'Dim line As String
'Dim zip As Integer
'Dim ZipRecord(5) As String

'zip = txtZip.Text
'sr = IO.File.OpenText(My.Resources.zips1)
'line = sr.ReadLine()

'ZipRecord = line.Split(",")

'txtState.Text = ZipRecord(3)
'txtCity.Text = ZipRecord(2)

End Sub

'Public Sub DisplayZip(ByVal thiszip As String)

' Dim ZipRecord(4) As String

' ZipRecord = thiszip.Split(",")

' txtState.Text = ZipRecord(2)
' txtCity.Text = ZipRecord(1)
' txtZip.Text = ZipRecord(0)

'End Sub
Private Sub txtZip_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtZip.Validated

Dim sr As StreamReader
Dim line As String
Dim zip As String

'Dim thiszip As String

'currentline += 1

'thiszip = Zips(currentline)

'DisplayZip(thiszip)

'Dim zipIndex As String
'Dim index As String


sr = IO.File.OpenText("zip1.csv")
line = sr.ReadLine
zip = txtZip.Text
Ziprecord = Zips


'DisplayZip(Zips(0))



Dim city As String
Dim state As String
Dim currentline As Integer

'Do While currentline < recCnt









'If line.Contains("Cedar Falls") Then
' txtCity.Text = Ziprecord(1)
'End If
'MessageBox.Show(line & vbNewLine & Ziprecord(1) & line.Count)

Ziprecord = line.Split(",")
'Ziprecord(2) += 1
'Ziprecord(1) += 1
'Ziprecord(0) = zip
Do Until line.Contains(zip)
line = sr.ReadLine()
zip = Zips(currentline)
Ziprecord = zip.Split(",")

city += Ziprecord(1)
state += Ziprecord(2)

currentline += 1
Loop


'txtCity.Text = Ziprecord(1)
'txtState.Text = Ziprecord(2)
'Ziprecord(0) += 1
'MessageBox.Show(line & vbNewLine & Ziprecord(1) & vbNewLine & zip)

'For Each line In Zips
'If line.Contains(zip) Then

'End If
'Next

'If Ziprecord(0) = zip Then
' txtState.Text = Ziprecord(2)
' txtCity.Text = Ziprecord(1)
'End If
'Loop


'If Ziprecord(0) = zip Then
' txtState.Text = Ziprecord(2)
' txtCity.Text = Ziprecord(1)
'End If

'Do Until line = txtZip.Text
' line = sr.ReadLine()
'Loop



' Do While sr.Peek <> -1
'line = sr.ReadLine
'If ZipRecord(0) = zip Then
'End If
' Loop
'zipIndex = ZipRecord(0)
'index = zipIndex.IndexOf(zip)
'MessageBox.Show("hello")

'
' txtZip.Text = line
'Loop




sr.Close()
End Sub

End Class

Viewing all articles
Browse latest Browse all 27355

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>