
Originally Posted by
utherson601
i was thinking more along the lines of
arrsavetext is a 1d array
arrtext is the 3d array
im trying to make them the same just by putting everything in arrtext into a location in arrsavetext then doing a streamwrite for it to save it
Even though I don't recommend using 3D Arrays...(in this case)...
This sure isn't any good method. Database would be way better...and structures would be better aswell...
Ar(5,5,5) already results in 216 textlines.
[highlight="VB.Net"] Private Ar(5, 5, 5) As Integer
Private Sub SaveArray(ByVal SaveLocation As String)
Dim strB As New System.Text.StringBuilder
For x = Ar.GetLowerBound(0) To Ar.GetUpperBound(0)
For y = Ar.GetLowerBound(1) To Ar.GetUpperBound(1)
For z = Ar.GetLowerBound(2) To Ar.GetUpperBound(2)
strB.AppendLine(String.Format("{0},{1},{2};{3}", x, y, z, Ar(x, y, z)))
Next
Next
Next
Using sWrite As New IO.StreamWriter(SaveLocation, False)
sWrite.Write(strB.ToString)
End Using
End Sub
Private Sub RetreiveArray(ByVal FileLocation As String)
If IO.File.Exists(FileLocation) Then
Dim Line As String = ""
Try
Using sRead As New IO.StreamReader(FileLocation)
While Not sRead.EndOfStream
Line = sRead.ReadLine
Dim split() As String = Line.Split(";"c)
Ar(split(0).Split(","c)(0), split(0).Split(","c)(1), split(0).Split(","c)(2)) = split(1)
End While
End Using
Catch ex As *********enceException
End Try
End If
End Sub[/highlight]
Jason probably knows a way faster solution(LINQ or w/e).
My version works aswell though. Might be a bit slow if you have a huge 3D Array...but huge 3D arrays = retarded in this case...
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
@Structures
[highlight="VB.Net"]
Private DateList As New List(Of CustomDate)
Public Structure CustomDate
Dim Day As Byte
Dim Month As Byte
Dim Year As Integer
End Structure
Private Sub AddDate(ByVal Day As Byte, ByVal Month As Byte, ByVal Year As Byte)
DateList.Add(New CustomDate With {.Day = Day, .Month = Month, .Year = Year})
End Sub
Private Sub RetreiveDates()
If DateLis*****unt <> 0 Then
For i = 0 To DateLis*****unt - 1
With DateList(i)
MsgBox(String.Format("{0}.{1}.{2}", .Day, .Month, .Year))
End With
Next
End If
End Sub
Private Sub SaveDateList(ByVal List As List(Of CustomDate), ByVal FileLocation As String)
Dim strB As New System.Text.StringBuilder
For i = 0 To Lis*****unt - 1
With List(i)
strB.AppendLine(String.Format("{0};{1};{2}", .Day, .Month, .Year))
End With
Next
Using sWrite As New IO.StreamWriter(FileLocation, False)
sWrite.Write(strB.ToString)
End Using
End Sub
Private Function RetreiveDateList(ByVal FileLocation As String) As List(Of CustomDate)
Dim L As New List(Of CustomDate)
Using sRead As New IO.StreamReader(FileLocation)
While Not sRead.EndOfStream
Dim Line As String = sRead.ReadLine
Dim CD As New CustomDate
CD.Day = Line.Split(";"c)(0)
CD.Month = Line.Split(";"c)(1)
CD.Year = Line.Split(";"c)(2)
L.Add(CD)
End While
End Using
Return L
End Function
Private Sub GetData()
DateList = RetreiveDateList("filelocation")
End Sub
[/highlight]
Still have to repeat myself...Databases > Textfiles.