Im having a little issue in my code that I wasnt expecting and Im not quite sure how to fix it.
normally in an example like this:
You would expect the prompt to be "1test" as defining test2 = "test" will not change test1 to "test" giving you the prompt "testtest"Code:Dim test1 As String = "1" Dim test2 As String = test1 test2 = "test" MsgBox(test1 & test2)
However, that is exactely what is happening when I use this principal on a two dimensional string array.
Where the comments are I am doing a series of commands that add to both nArray and patRemove.count. However, sometimes after the commands patRemove.count will still not be high enough (equal to unPatlist.count). On those instances I need patRemove.Count to start back at 0 and for nArray to reinitialize itself from BUArray (BackUp Array). But when it goes to reinitialize, BUArray has been changing alongside nArray isstead of staying with the original data even though I make absolutely no mention anywhere in the code to change BUArray.Code:Public Shared Sub MakeSchedule(ByVal BUArray As String(,), ByVal unPatList As List(Of String)) Dim patRemove As New List(Of Integer) Do Until patRemove.Count = unPatList.Count Dim nArray As String(,) = BUArray patRemove = New List(Of Integer) For x as integer = 0 to 8 'Do a bunch of code to fill in nArray 'add to PatRemove.count Next Loop End Sub
So my question is, why is changing nArray changing BUArray when the only mention of BUArray is when I am setting nArray? wouldnt it work just like the above example with test1 and test2?
Thank You,
-Z
As a side note, I should mention that I can tell BUArray is changing from the following code
Code:sb1 = New StringBuilder sb1.AppendLine("Rooms: " & patRemove.Count) sb1.AppendLine("AMT") For x As Integer = 0 To BUArray.GetUpperBound(1) Dim str As String = "" For y As Integer = 0 To BUArray.GetUpperBound(0) str += BUArray(y, x) & "," Next sb1.AppendLine(str) Next




Reply With Quote
