can some chech this out and point out my error

freddie_26

Newcomer
Joined
Mar 29, 2003
Messages
6
Location
st.Lucia
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()
 
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.

Visual Basic:
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()
 
Back
Top