Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Zombie

Copying text to array

This topic is 6941 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I use the following code to copy 1 line of text file to 1 index of array.
Public Sub CopyFileToArray(zarray As Variant, filename As String, maxlines As Integer)
Dim LinesFromFile As String, NextLine As String

Open filename For Input As #1
  For xi = 1 To maxlines
   Line Input #1, NextLine
   LinesFromFile = LinesFromFile + NextLine + Chr(13) + Chr(10)
   zarray(xi) = NextLine
  Next
Close #1
End Sub
 
It needs to be updated like this: Before the array was like this- Array(1 to x) as string Now it''s like this- Array(1 to x,1 to y, 1 to z, 1 to a) as string I ''ve separated the information the program needs to get from text file with commas(,). Example, again- info1,info2,info3,info4 x y z a The sub needs to read the text that is separated by commas and write it to the array''s corresponding indices. How to do that? (Hope you got it, I''m not good to explain things as you can see )

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!