VB.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 300,344 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,571 people online right now. Registration is fast and FREE... Join Now!




Need help with manipulating and using arrays

 

Need help with manipulating and using arrays, strings

Sadaiy

2 Jul, 2009 - 08:20 AM
Post #1

D.I.C Head
**

Joined: 3 Oct, 2008
Posts: 106



Thanked: 2 times
My Contributions
Please, I get some errors, please help, here is my code:

CODE

Public Class Form1
    Dim states(49) As String
    Dim tail As Integer = 0
    Dim temp As String


    Private Sub btnInsert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInsert.Click
        states(tail) = txtBox.Text
        tail = tail + 1

        For passNum As Integer = 1 To (tail - 1)
            For i As Integer = 1 To (tail - passNum)
                If (states(i - 1) > states(i)) Then
                    temp = states(i - 1)
                    states(i - 1) = states(i)
                    states(i) = temp
                End If
            Next
        Next
    End Sub

    Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click

    End Sub

    Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
        If states(0) <> "" Then
            For i As Integer = 0 To tail
                lstOutput.Items.Add(states(i))
            Next
        Else
            MessageBox.Show("You have not entered any states yet.")
        End If
        
    End Sub
End Class


This is my error: System.Argument.Null.Exception for the line "lstOutput.Items.Add(states(i))"

PLease assist me

User is offlineProfile CardPM
+Quote Post


PsychoCoder

RE: Need Help With Manipulating And Using Arrays

2 Jul, 2009 - 08:24 AM
Post #2

Dyslexics Untie!
Group Icon

Joined: 26 Jul, 2007
Posts: 14,704



Thanked: 501 times
Dream Kudos: 11450
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

My Contributions
This is VB.NET code so I'm moving this there smile.gif
User is offlineProfile CardPM
+Quote Post

pjlasl

RE: Need Help With Manipulating And Using Arrays

2 Jul, 2009 - 09:01 AM
Post #3

New D.I.C Head
*

Joined: 2 Jul, 2009
Posts: 1

I copied your code into a form and did not get an error blink.gif
User is offlineProfile CardPM
+Quote Post

mark.bottomley

RE: Need Help With Manipulating And Using Arrays

2 Jul, 2009 - 11:05 AM
Post #4

D.I.C Addict
****

Joined: 22 Apr, 2009
Posts: 780



Thanked: 127 times
My Contributions
I believe that the listbox has a Sort attribute that will order the states for you saving the bubble sort code you are using.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 05:50PM

Live VB.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month