Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble with Array overwritting itself

Status
Not open for further replies.

Jewel142

ISP
Jun 17, 2009
39
Hi Everyone,

I've just started working with arrays and I can't seem to get it to work properly. The first item saves just find but my array keeps overwritting itself. Any suggestions?

-----------------------

'Declare Arrays A_{Array Name}

Private A_EE_NBR(0) As Integer
Private EE_COUNTER As Integer = A_EE_NBR.GetUpperBound(0)
Private NBR_EE As Integer
Private NEXT_ID As Integer
Private A_FIRSTNAME(15) As String

Private A_LASTNAME(15) As String
Private A_SSN(15) As String
Private A_HRLYRATE(15) As String

'***PRIVATE SUB PROCEDURE TO ADD LINE ITEMS TO ARRAY***
Private Sub Add_To_Array()
Dim EE_NBR As Integer

Dim i As Integer
For i = 0 To A_EE_NBR.Count + 1

Next i

A_FIRSTNAME(0) = firstNameTextBox.Text
A_LASTNAME(0) = lastNameTextBox.Text
A_SSN(0) = ssnTextBox.Text
A_HRLYRATE(0) = hourlyRateTextBox.Text

NBR_EE = EE_COUNTER + 1

eeCountTextBox.Text = NBR_EE.ToString("N0")
eeIDTextBox.Text = EE_NBR.ToString("N0")

End Sub

Thanks for your help!

Jewel
 
Although I'm not entirely sure what you're trying to accomplish, it appears to me you want to use your counter variable (e.g., i or NBR_EE) as the array index, rather than the constant index 0. As written, the first element of the array (number 0) is written to (and on subsequent calls, overwritten) every time the add_to_array sub is called.

Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top