<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Array and Listbox' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Array and Listbox' posted on the 'VB.NET' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2012 Programmers Heaven</copyright>
    <pubDate>Thu, 09 Feb 2012 07:27:42 -0800</pubDate>
    <lastBuildDate>Thu, 09 Feb 2012 07:27:42 -0800</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Array and Listbox</title>
      <link>http://www.programmersheaven.com/mb/VBNET/360197/360197/array-and-listbox/</link>
      <description>Im new to programming please help me.&lt;br /&gt;
I’ve given explanation in the code where I need help&lt;br /&gt;
&lt;br /&gt;
Public Class Form1&lt;br /&gt;
    Inherits System.Windows.Forms.Form&lt;br /&gt;
&lt;br /&gt;
Dim StreamWriter As System.IO.StreamWriter&lt;br /&gt;
    Dim StreamReader As System.IO.StreamReader&lt;br /&gt;
    Dim strLine As String&lt;br /&gt;
    Dim strName As String&lt;br /&gt;
    Dim strPhoneNumber As String&lt;br /&gt;
    Dim IntCounter As Integer&lt;br /&gt;
    Dim strNames(100) As String&lt;br /&gt;
    Dim strNumbers(100) As Integer&lt;br /&gt;
&lt;br /&gt;
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load&lt;br /&gt;
        Dim intButton As Integer&lt;br /&gt;
        intButton = MessageBox.Show("Do you want to initialize the file?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Information)&lt;br /&gt;
        If intButton = Windows.Forms.DialogResult.No Then&lt;br /&gt;
            MessageBox.Show(" File was not initialized!", "", MessageBoxButtons.OK, MessageBoxIcon.Information)&lt;br /&gt;
        Else&lt;br /&gt;
            StreamWriter = System.IO.File.CreateText("MEMBERS.TXT")&lt;br /&gt;
            StreamWriter.Close()&lt;br /&gt;
&lt;br /&gt;
            For IntCounter = 0 To 100&lt;br /&gt;
                StreamWriter = System.IO.File.AppendText("MEMBERS.TXT")&lt;br /&gt;
                StreamWriter.Close()&lt;br /&gt;
            Next IntCounter&lt;br /&gt;
            MessageBox.Show(" File was initialized", "", MessageBoxButtons.OK, MessageBoxIcon.Information)&lt;br /&gt;
        End If&lt;br /&gt;
&lt;br /&gt;
        If System.IO.File.Exists("MEMBERS.TXT") = True Then&lt;br /&gt;
            StreamReader = System.IO.File.OpenText("MEMBERS.TXT")&lt;br /&gt;
            IntCounter = 0&lt;br /&gt;
            Do Until StreamReader.Peek = -1&lt;br /&gt;
                strLine = StreamReader.ReadLine()&lt;br /&gt;
                strName = strLine.Substring(0, 20)&lt;br /&gt;
                strPhoneNumber = strLine.Substring(20, 12)&lt;br /&gt;
                strNames(IntCounter) = strName&lt;br /&gt;
                strNumbers(IntCounter) = strPhoneNumber&lt;br /&gt;
                NamesListBox.Items.Add(strNames(IntCounter) &amp;amp; strNumbers(IntCounter))&lt;br /&gt;
                IntCounter = IntCounter + 1&lt;br /&gt;
            Loop&lt;br /&gt;
            StreamReader.Close()&lt;br /&gt;
        End If&lt;br /&gt;
&lt;br /&gt;
    End Sub&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Private Sub SaveButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SaveButton.Click&lt;br /&gt;
        If System.IO.File.Exists("MEMBERS.TXT") Then&lt;br /&gt;
            StreamWriter = System.IO.File.AppendText("MEMBERS.TXT")&lt;br /&gt;
            StreamWriter.Write(NameTextBox.Text.PadRight(30))&lt;br /&gt;
            StreamWriter.Write("")&lt;br /&gt;
            StreamWriter.WriteLine(NumberTextBox.Text)&lt;br /&gt;
            NameTextBox.Text = ""&lt;br /&gt;
            NumberTextBox.Text = ""&lt;br /&gt;
            NameTextBox.Focus()&lt;br /&gt;
            StreamWriter.Close()&lt;br /&gt;
        Else&lt;br /&gt;
            MessageBox.Show("File does not exist")&lt;br /&gt;
        End If&lt;br /&gt;
&lt;br /&gt;
    End Sub&lt;br /&gt;
&lt;br /&gt;
Private Sub ClearButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ClearButton.Click&lt;br /&gt;
        NameTextBox.Text = ""&lt;br /&gt;
        NumberTextBox.Text = ""&lt;br /&gt;
&lt;br /&gt;
    End Sub&lt;br /&gt;
&lt;br /&gt;
    Private Sub ExitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ExitButton.Click&lt;br /&gt;
        Close()&lt;br /&gt;
    End Sub&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    Private Sub AddNewButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddNewButton.Click&lt;br /&gt;
        NameTextBox.Text = ""&lt;br /&gt;
        NumberTextBox.Text = ""&lt;br /&gt;
        NameTextBox.Focus()&lt;br /&gt;
    End Sub&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    Private Sub EditButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles EditButton.Click&lt;br /&gt;
        NameTextBox.Focus()&lt;br /&gt;
        DeleteButton.Visible = True&lt;br /&gt;
        UpdateButton.Visible = True&lt;br /&gt;
       &lt;br /&gt;
    End Sub&lt;br /&gt;
&lt;br /&gt;
    End Sub&lt;br /&gt;
&lt;br /&gt;
    Private Sub DeleteButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DeleteButton.Click&lt;br /&gt;
       &lt;br /&gt;
      HOW DO I DELETE THE RECORD FROM THE ARRAY &lt;br /&gt;
    End Sub&lt;br /&gt;
&lt;br /&gt;
    Private Sub UpdateButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles UpdateButton.Click&lt;br /&gt;
HOW DO I SAVE THE WHOLE FILE WITH THE AMMENDMENTS.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    Private Sub NamesListBox_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles &lt;br /&gt;
&lt;br /&gt;
I WANT WHEN THE USER CLIKS THE NAME IN THE LISTBOX, TO APPEAR IN THE NAME NUMBER TEXBOXS. &lt;br /&gt;
&lt;br /&gt;
    End Sub&lt;br /&gt;
End Class</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/VBNET/360197/360197/array-and-listbox/</guid>
      <pubDate>Tue, 29 May 2007 08:37:36 -0800</pubDate>
      <category>VB.NET</category>
    </item>
    <item>
      <title>Re: Array and Listbox</title>
      <link>http://www.programmersheaven.com/mb/VBNET/360197/360199/re-array-and-listbox/#360199</link>
      <description>What exactly do you need?&lt;br /&gt;
&lt;br /&gt;
So basically you want to create a program that opens a Text file, inputs the text into a Multiline Texbox, make changes, click Update and have those changes be saved? Or are you doing something else?&lt;br /&gt;
&lt;br /&gt;
Please elaborate on what you are trying to do and I will be glad to assist.</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/VBNET/360197/360199/re-array-and-listbox/#360199</guid>
      <pubDate>Tue, 29 May 2007 10:21:56 -0800</pubDate>
      <category>VB.NET</category>
    </item>
    <item>
      <title>Re: Array and Listbox</title>
      <link>http://www.programmersheaven.com/mb/VBNET/360197/360208/re-array-and-listbox/#360208</link>
      <description>: What exactly do you need?&lt;br /&gt;
: &lt;br /&gt;
: So basically you want to create a program that opens a Text file, &lt;br /&gt;
: inputs the text into a Multiline Texbox, make changes, click Update &lt;br /&gt;
: and have those changes be saved? Or are you doing something else?&lt;br /&gt;
: &lt;br /&gt;
: Please elaborate on what you are trying to do and I will be glad to &lt;br /&gt;
: assist.&lt;br /&gt;
&lt;br /&gt;
Basically i want to design a membership Name and Telephone List form using the following command buttons. &lt;br /&gt;
&lt;br /&gt;
Edit&lt;br /&gt;
Add New;&lt;br /&gt;
Update;&lt;br /&gt;
Delete;&lt;br /&gt;
Cancel;&lt;br /&gt;
Save;&lt;br /&gt;
Clear, and &lt;br /&gt;
Exit&lt;br /&gt;
&lt;br /&gt;
The names and phone numbers of members are stored in a sequential text file called MEMBERS.TXT which i have created.&lt;br /&gt;
&lt;br /&gt;
When the program is loaded, names and telephone numbers should be read from the file and stored in an array or arrays in memory and then, from memory, the names and telephone numbers are displayed in alphabetical names sequence in a list box.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I used two textboxs to hold the Name and the other to hold the Number&lt;br /&gt;
&lt;br /&gt;
When a name in the listbox is selected (clicked) the name and corresponding phone number should be should be displayed in the textboxes but i cant manage to do this.&lt;br /&gt;
&lt;br /&gt;
To change any fields, the user first uses the Edit button to enable the textboxes to be changed.&lt;br /&gt;
&lt;br /&gt;
The user makes the amendments to the textboxes and uses the update button to effect the change in memory. I need your help on this too.&lt;br /&gt;
&lt;br /&gt;
To delete an item, Delete is used. But i dont know how to do this using sequantial Files. Thanks for your help.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/VBNET/360197/360208/re-array-and-listbox/#360208</guid>
      <pubDate>Tue, 29 May 2007 11:41:50 -0800</pubDate>
      <category>VB.NET</category>
    </item>
    <item>
      <title>Re: Array and Listbox</title>
      <link>http://www.programmersheaven.com/mb/VBNET/360197/360218/re-array-and-listbox/#360218</link>
      <description>Is this for a project at school? If you are doing this for a school project I will be more then willing to help you arrive at an answer by answering questions, but I will not write the code for you it won't help you learn.&lt;br /&gt;
&lt;br /&gt;
I did create a mock program do perform exactly what you want it to do, with 2 text boxes and a list box full of each member on file. I am more than willing to share it with you, but it uses a different method of writing files then you have set up in yours, and it also uses a bit more advanced programming, so if your looking to learn for school it might not be the way to go...&lt;br /&gt;
&lt;br /&gt;
Let me know your intentions, I am more than willing to walk you through writing one step by step if you want to learn</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/VBNET/360197/360218/re-array-and-listbox/#360218</guid>
      <pubDate>Tue, 29 May 2007 13:25:36 -0800</pubDate>
      <category>VB.NET</category>
    </item>
    <item>
      <title>Re: Array and Listbox</title>
      <link>http://www.programmersheaven.com/mb/VBNET/360197/360267/re-array-and-listbox/#360267</link>
      <description>&lt;br /&gt;
I'll be more than happy for you walk me though your moch program. I really want to learn and not just to finish the project and one again thanks.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/VBNET/360197/360267/re-array-and-listbox/#360267</guid>
      <pubDate>Wed, 30 May 2007 00:15:24 -0800</pubDate>
      <category>VB.NET</category>
    </item>
    <item>
      <title>Re: Array and Listbox</title>
      <link>http://www.programmersheaven.com/mb/VBNET/360197/360291/re-array-and-listbox/#360291</link>
      <description>Well here goes:&lt;br /&gt;
&lt;br /&gt;
Typically when I am assigned a new project, I break it down into what parts I am going to need to complete it. For your problem statement I determined that I would need 2 Labels (to designate which text box is which) 2 Text boxes (for entering MemberName and MemberNumber) a ListBox (I like to use Listviews myself, but I am using a listbox since that was what you said you were using) and finally 8 buttons, one for each operation you wanted to do.&lt;br /&gt;
&lt;br /&gt;
Now that we have drawn those objects onto our form, and before we write any code, lets put some proper names on the Controls so we don't get confused as the project gains more complexity (this program is rather simple, if I didn't use good naming schemes, my 2 year project at work would really be difficult to work on):&lt;br /&gt;
&lt;br /&gt;
when naming controls, try to designate what control it is with the name by adding three lower case letters to the begining. I named the objects as followed:&lt;br /&gt;
txtMemberName, txtMemberNumber, lblMemeberName, lblMemberNumber, lstNames, btnEdit, btnAdd, btnUpdate, btnDelete, btnCancel, btnSave, btnClear, btnExit.&lt;br /&gt;
&lt;br /&gt;
Now that we have our form drawn up, lets take a crack at coding functionality.&lt;br /&gt;
&lt;br /&gt;
So I wrote a few custom Subroutines (if you didn't know how to do this, type in Sub Bob() and hit enter [should auto put in the end sub] and now you can call the code in the Bob subroutine from anywhere else on the form (Form1_Load etc). This comes in handy when you have a few lines of code that will get repeated a lot such as the code to repopulate the listBox.&lt;br /&gt;
&lt;br /&gt;
Read the commenting under each function for the specifics, but here is a breif description of each function I wrote:&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
grabData(fileName as String) - This function is used to grab the names and numbers out of the fileName supplyed. If that filename does not exist the program will crash. I created a file with 2 lines in it, first line was name, second line was number and named it MEMBERS.TXT and saved it to the bin folder of my project to avoid the crash. If you want to fix the crash, you need to handle for no data in the fillListBox function.&lt;br /&gt;
&lt;br /&gt;
Note on grabData - If you notice, I use the ReDim Preserve keywords on my two arrays (at the top they are declared as MemberName(0) and MemberNumber(0) which normally meens they can only hold 1 value in cell (0). Well since I wanted this program to be able to handle any number of members, the ReDim Preserve Array(Array.Length) adds on a new cell. Heres how:&lt;br /&gt;
&lt;br /&gt;
When I declare an array i do this Dim Arr(10) as integer, I can now store values in Arr(0), Arr(1) ... Arr(10). So the Length of Arr is 11. So if I say ReDim Arr(Arr.Length) I am really saying ReDim Arr(11) which increases the size by 1.&lt;br /&gt;
&lt;br /&gt;
Normally when you do a reDim it erases the values that used to be in the array, but when you include the Preserve keyword, it saves them.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
writeVarsToFile(MName() as String, MNumber() as String, fileName as string) - This function writes sequentially writes each MemberName and MemberNumber from the two arrays supplied to it to the fileName you pass it.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
fillListBox(MName() as String, LB as ListBox) - This function fills the ListBox you pass it with every name in the passed MName array. Assuming that there is a MemberNumber for each MemberName, we will use ListBox.SelectedIndex in the end to know which item in the array we have selected.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
removeMember(index as integer) - This function removes a member from the array. Note: You have to save the file with the save button to update the text file for any changes. If you notice, to remove an item, I just shift every value up one by saying Array(x) = Array(x+1) at the end, I use ReDim Preserve to shrink the array length down by 1 and remove the now duplicated value at the end&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
addMember(MName as String, MNumber as String) - This function simply adds a new cell to the array and puts Mname and Mnumber in.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
The rest of the code is event driven.&lt;br /&gt;
&lt;br /&gt;
On Load I read the text file and populate the Listbox with the data now in memory (I am not handling for the file not existing, you should add that)&lt;br /&gt;
&lt;br /&gt;
When the listbox calls SelectedIndexChanged (when you select something new) the Textboxes up top are updated to display the information underneath the arrays at that selected index (since we sync up the MemberName array with the listBox items, SelectedIndex 0 = Array(0).&lt;br /&gt;
&lt;br /&gt;
When the user clicks Add New, the text boxes are enabled and cleared. You can add in a new name and number and click the add New button again to add it to the list. If you look at the code under the add new button, I set a boolean called AddNewMode to true on the first click, and set it back to false on the second click.&lt;br /&gt;
&lt;br /&gt;
When a user selects a new item on the listbox, it sets AddNewMode and EditMode to false incase you were in the middle of making changes and decided to stop.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I hope this program helps (code included in next post). I didn't finish all the buttons code because I am not sure exactly what each button needs to do, but you can probably just modify this code to get it to do everything you need.&lt;br /&gt;
&lt;br /&gt;
If you have anymore questions, or don't understand any parts of this code, just reply back I will gladly and indepthly explain any part of it to help you learn.&lt;br /&gt;
&lt;br /&gt;
Sean Campbell - Programmer / Musician / Life Philosopher&lt;br /&gt;
check out my Music site &lt;a href="http://www.jamjunky.com/firesickle"&gt;http://www.jamjunky.com/firesickle&lt;/a&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/VBNET/360197/360291/re-array-and-listbox/#360291</guid>
      <pubDate>Wed, 30 May 2007 06:37:13 -0800</pubDate>
      <category>VB.NET</category>
    </item>
    <item>
      <title>Re: Array and Listbox</title>
      <link>http://www.programmersheaven.com/mb/VBNET/360197/360292/re-array-and-listbox/#360292</link>
      <description>&lt;pre class="sourcecode"&gt;

    Dim MemberName(0) As String
    Dim MemberNumber(0) As String
    Dim EditMode As Boolean = False
    Dim AddNewMode As Boolean = False
    Dim appPath As String 'needed for application Startup folder

    Sub grabData(ByVal FileName As String)

        'This subroutine grabs Name and Number information
        'from the supplyed fileName and inserts them into Dynamic
        'Arrays 

        Dim FF As Integer = FreeFile()
        'FreeFile provides an unused Integer to use
        'for a FileOpen command

        Try
            'Try keep program from crashing whenever an error occurs in the
            'contained code. Underneath Catch I put in some MsgBox code to display
            'any errors that occur.

            FileOpen(FF, FileName, OpenMode.Input)
            'This opens the File FileName in input mode (which allows me to read
            'each line of text out of the file into strings)

            Do While Not EOF(FF)
                'This loop runs until we reach the end of FileNum FF (same filenum as fileopen)
                'The Input statements grab a whole line as an object
                'and stick 
                Input(FF, MemberName(MemberName.Length - 1))
                Input(FF, MemberNumber(MemberNumber.Length - 1))

                If Not EOF(FF) Then
                    ReDim Preserve MemberName(MemberName.Length)
                    ReDim Preserve MemberNumber(MemberNumber.Length)
                    'I will be sure to explain the reDims in my post
                    'this(part Is tricky)
                End If
            Loop

            FileClose(FF)

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

    End Sub

    Sub writeVarsToFile(ByVal MName() As String, ByVal MNum() As String, ByVal FileName As String)

        'This subroutine writes all values in MName and MNum into the specified file
        'as text.
        'It will insert MName(0) on the first line MNum(0) on the next 
        '   MName(1) on the next ETC.

        Dim FF As Integer = FreeFile()

        Try

            FileOpen(FF, FileName, OpenMode.Output)

            Dim i As Integer = 0
            'We will use i to designate where we are at in the Arrays

            Do While i &amp;lt; MemberName.Length
                PrintLine(FF, MemberName(i))
                PrintLine(FF, MemberNumber(i))
                'PrintLine writes the variable(s) to file (without quotes)
                ' and inserts a LineFeed after it
                i += 1 'incriment i by 1
            Loop

            FileClose(FF)

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

    End Sub

    Sub fillListBox(ByVal MName() As String, ByVal LB As ListBox)
        Dim i As Integer
        LB.Items.Clear()
        For i = 0 To MName.Length - 1
            LB.Items.Add(MName(i))
        Next
    End Sub

    Sub removeMember(ByVal index As Integer)

        Dim i As Integer
        For i = index To MemberName.Length - 2
            'Remove data by shifting everything up one index
            MemberName(i) = MemberName(i + 1)
            MemberNumber(i) = MemberNumber(i + 1)
        Next
        'take off empty array cell
        'Preserve keyword keeps old values from being erased
        ReDim Preserve MemberName(MemberName.Length - 2)
        ReDim Preserve MemberNumber(MemberNumber.Length - 2)

        fillListBox(MemberName, lstNames) 'refresh data in listBox

    End Sub

    Sub addMember(ByVal MName As String, ByVal MNumber As String)
        'Add on a new cell to end of array
        ReDim Preserve MemberName(MemberName.Length)
        ReDim Preserve MemberNumber(MemberNumber.Length)
        'Add in the next values
        MemberName(MemberName.Length - 1) = MName
        MemberNumber(MemberNumber.Length - 1) = MNumber

        fillListBox(MemberName, lstNames) 'refresh data in listbox

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'These two functions set appPath to be the fully qualified
        'path name of where the application is running at

        'If you are running the program in debug mode, this path
        'is the Bin folder inside of your project folder

        'On my machine this var is C:\My VS Projs\ProjectName\Bin\
        appPath = Application.StartupPath
        If appPath.Substring(appPath.Length - 1) &amp;lt;&amp;gt; "\" Then appPath &amp;amp;= "\"
        ' String &amp;amp;= "Text"  is an append function. &amp;amp;= adds the Concatinates onto the end.

        'On Load we want to initialize the Form's Dataset
        grabData(appPath &amp;amp; "MEMBERS.TXT")
        fillListBox(MemberName, Me.lstNames) 'Pass the function Membername array


        'These will be enabled in AddNew mode and in EditMode
        txtMemberName.Enabled = False
        txtMemberNumber.Enabled = False

    End Sub

    Private Sub lstNames_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstNames.SelectedIndexChanged
        'This function is called whenever the user changes what is selected in listbox
        If lstNames.SelectedIndex &amp;lt; MemberName.Length Then
            'This function makes sure that the item selected in the listbox
            'is not a higher index then what items the MemberName array has
            'This case should not be common, but it is best to include it to keep
            'the program from crashing if it did
            txtMemberName.Text = MemberName(lstNames.SelectedIndex)
            txtMemberNumber.Text = MemberNumber(lstNames.SelectedIndex)

            'When the user selects something on the lstBox, set modes = false
            'and disable textboxes
            txtMemberName.Enabled = False
            txtMemberNumber.Enabled = False
            AddNewMode = False
            EditMode = False
        End If
    End Sub

    Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        If AddNewMode = False Then
            txtMemberName.Text = ""
            txtMemberNumber.Text = ""
            txtMemberName.Enabled = True
            txtMemberNumber.Enabled = True
            txtMemberName.Focus()
            AddNewMode = True
        Else
            addMember(txtMemberName.Text, txtMemberNumber.Text)
            txtMemberName.Enabled = False
            txtMemberNumber.Enabled = False
            AddNewMode = False
        End If
    End Sub

    Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click
        If EditMode = False Then
            txtMemberName.Enabled = True
            txtMemberNumber.Enabled = True
            txtMemberName.Focus()
            EditMode = True
        Else
            If lstNames.SelectedIndex &amp;lt; MemberName.Length Then
                MemberName(lstNames.SelectedIndex) = txtMemberName.Text
                MemberNumber(lstNames.SelectedIndex) = txtMemberNumber.Text
            End If
            txtMemberName.Enabled = False
            txtMemberNumber.Enabled = False
            EditMode = False
        End If
    End Sub

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        writeVarsToFile(MemberName, MemberNumber, appPath &amp;amp; "MEMBERS.TXT")
    End Sub

    Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
        If lstNames.SelectedIndex &amp;lt; MemberName.Length Then
            removeMember(lstNames.SelectedIndex)
        End If
    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        txtMemberName.Enabled = False
        txtMemberNumber.Enabled = False
        AddNewMode = False
        EditMode = False
        lstNames.SelectedIndex = 0
    End Sub

    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        End  'just End closes the Application
    End Sub

    Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click

    End Sub

    Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click

    End Sub
&lt;/pre&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/VBNET/360197/360292/re-array-and-listbox/#360292</guid>
      <pubDate>Wed, 30 May 2007 06:37:48 -0800</pubDate>
      <category>VB.NET</category>
    </item>
    <item>
      <title>Re: Array and Listbox</title>
      <link>http://www.programmersheaven.com/mb/VBNET/360197/369398/re-array-and-listbox/#369398</link>
      <description>did you get it done need the same help.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/VBNET/360197/369398/re-array-and-listbox/#369398</guid>
      <pubDate>Tue, 12 Feb 2008 05:53:41 -0800</pubDate>
      <category>VB.NET</category>
    </item>
    <item>
      <title>Re: Array and Listbox</title>
      <link>http://www.programmersheaven.com/mb/VBNET/360197/381832/re-array-and-listbox/#381832</link>
      <description>Hi&lt;br /&gt;
&lt;br /&gt;
I see you did this program quite some time ago but im hoping you can help me. I took pieces of your code and added it to mine where my code wasnt working but now everytime i try to run my program it gives me an error msg stating that it couldnt find my folder members.txt. Do you possibly know what could be wrong and how to fix it?&lt;br /&gt;
&lt;br /&gt;
Thanks&lt;br /&gt;
Kirsten&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/VBNET/360197/381832/re-array-and-listbox/#381832</guid>
      <pubDate>Thu, 13 Nov 2008 06:05:28 -0800</pubDate>
      <category>VB.NET</category>
    </item>
    <item>
      <title>Re: Array and Listbox</title>
      <link>http://www.programmersheaven.com/mb/VBNET/360197/381834/re-array-and-listbox/#381834</link>
      <description>Hi Kirsten, &lt;br /&gt;
&lt;br /&gt;
I would love to help you figure out what is wrong with your code, but you'll have to copy and paste it into a post for me to read it and see whats wrong.&lt;br /&gt;
&lt;br /&gt;
I'd suggest starting a new topic since this one is from May 2007 and has a load of replys already.&lt;br /&gt;
&lt;br /&gt;
Look forward to helping,&lt;br /&gt;
Firesickle.com</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/VBNET/360197/381834/re-array-and-listbox/#381834</guid>
      <pubDate>Thu, 13 Nov 2008 06:19:03 -0800</pubDate>
      <category>VB.NET</category>
    </item>
  </channel>
</rss>
