Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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()

  • *Experts*
Posted

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()

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

  • *Experts*
Posted
Okay... did you try the code above? What were the results?

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...