This is a homework assignment. I have the hardest time with arrays and I believe that is what is being a pain in my butt currently. I'm getting an argument null exception, which I believe is translating to "Tony you messed up another array." A jumping off point would be greatly appreciated. There is currently a .txt file with 8 entries, in the format

short, tony
555-1212

I hope this is enough data to help you help me.

Thank you in advance.

Public Class Form1
    'structure to hold the information of club memebers

    Structure group
        Dim name As String
        Dim num As String
        
    End Structure
    Dim listsize As Integer


    Dim memNamedata As Integer
    Dim memPhonedata As Integer


    Dim memList(8) As group
    Dim lines As Integer





    'filling the form at loadout
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        displayarray()

    End Sub

    Private Sub UpdateToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UpdateToolStripMenuItem.Click

    End Sub

    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
        End

    End Sub

    Private Sub ModifyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ModifyToolStripMenuItem.Click
        Dim updatename As String
        Dim updatenum As String
        updatename = nameinput.Text
        updatenum = phoneinput.Text

        memList(memNamedata).name = updatename
        memList(memPhonedata).num = updatenum

        displayarray()


    End Sub

    Private Sub AddToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddToolStripMenuItem.Click
        Dim name As String
        Dim phone As String

        name = nameinput.Text
        phone = phoneinput.Text
        listsize += 1


        memList(listsize).name = name
        memList(listsize).num = phone

        displayarray()


    End Sub
    Sub displayarray()
        memberlstbox.Items.Clear()
        For members As Integer = 0 To listsize
            memberlstbox.Items.Add(memList(members).name)

        Next
    End Sub
    Sub loadarray()
        'reading in file
        Dim sr As IO.StreamReader
        sr = IO.File.OpenText("memberphones.txt")
        Do While (sr.Peek <> -1)
            sr.ReadLine()
            sr.ReadLine()
            lines += 1
        Loop
        sr.Close()
        listsize = lines - 1

        sr = IO.File.OpenText("memberphones.txt")
        For memsize As Integer = 0 To 8
            memList(memsize).name = sr.ReadLine
            memList(memsize).num = sr.ReadLine
        Next
        sr.Close()
    End Sub



    Private Sub DeleteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeleteToolStripMenuItem.Click

    End Sub

    Private Sub memberlstbox_selectedtext(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles memberlstbox.SelectedIndexChanged
        memNamedata = memberlstbox.SelectedIndex
        memPhonedata = memberlstbox.SelectedIndex
        nameinput.Text = memberlstbox.SelectedItem
        phoneinput.Text = memList(memPhonedata).num

    End Sub
End Class

For memsize As Integer = 0 To 8
memList(memsize).name = sr.ReadLine
memList(memsize).num = sr.ReadLine
Next

Your array measures 8... Count the for cycle from 0 to 7

Edited 5 Years Ago by Nichito: n/a

This article has been dead for over six months. Start a new discussion instead.