I`ve been sitting here for a while now, but can`t figure out what I`m doing wrong. I`m hoping that someone out here can help me to solve my problem. I receive the message. that there are noe object reference set to this instance of object. Can anybody tell meg Why?
Ive got:
Ive got:
Visual Basic:
Structure individual
Dim name1 As String
Dim dato As String
Dim address As String
Dim Phonenumber As String
End Structure
Dim Person(100) As individual
Dim numPosts as integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim sr As StreamReader = File.OpenText("Personalia.txt")
Do While (sr.Peek <> -1) And (numPosts< Person.GetUpperBound(0))
numPosts += 1
Person(numPosts ).name1 = sr.ReadLine
Person(numPosts ).dato = sr.ReadLine
Person(numPosts ).address = sr.ReadLine
Person(numPosts ).Phonenumber = sr.ReadLine
Loop
....
end sub
Function FindName(ByVal name1) As String
Dim sr As StreamReader = File.OpenText("Personalia.txt")
Dim First, Mid, Last As Integer
Dim foundFlag As Boolean
First= 1
Last= numPosts
Do While (first<= last) And (Not foundFlag)
Mid= CInt((first+ last) / 2)
Select Case Person(Mid).name1.ToUpper
Case name
foundFlag = True
Case Is > name1
last= first- 1
Case Is < name1
last= first+ 1
End Select
Loop
If foundFlag Then
ListBox1.Items.Add(Person(mid).name1)
Else
MessageBox.Show("nothing")
End If
End Function