freddie_26 Posted March 29, 2003 Posted March 29, 2003 i'm trying to add words to a text file that i have already created which is in the form of a array. Is this the correct way to do this. the text file is like this rat, mice, that do, any, the it seem that i'm able to add but when i go back to my program to see the words itcrashes with an error message saying "index was outside the bound of the array" thanks Dim flower As String Dim tree() As String Dim m As Integer Dim sw As IO.StreamWriter = IO.File.AppendText("words.txt" ) rm(m, 0) = InputBox("Please enter English Word" ) rm(m, 1) = InputBox("Please enter French Word" ) rm(m, 2) = InputBox("Please enter German Word" ) flower = Join(tree, "," ) sw.WriteLine(flower) sw.Close() Quote
*Experts* Bucky Posted March 29, 2003 *Experts* Posted March 29, 2003 You're using several different varibles here, some of which I don't see declared. What is rm? From what I see, this looks like more along the lines of what you want. You need to declare tree to say how many elements it will hold, and then set the values of the InputBox calls to that array. Dim flower As String Dim tree(2) As String ' Declare an array with a length of 3 Dim m As Integer ' What is this for? It will always be 0 Dim sw As IO.StreamWriter = IO.File.AppendText("words.txt") tree(0) = InputBox("Please enter English Word" ) tree(1) = InputBox("Please enter French Word" ) tree(2) = InputBox("Please enter German Word" ) flower = Join(tree, ",") sw.WriteLine(flower) sw.Close() Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
freddie_26 Posted March 29, 2003 Author Posted March 29, 2003 forgot to say that the array is two dimensional dim rm ( 30,3) as string Quote
*Experts* Bucky Posted March 29, 2003 *Experts* Posted March 29, 2003 Okay... did you try the code above? What were the results? Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.