Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

here's is what i want to do

 

i have a data in a text file in a array, i want to read the out the english words compared with the french and display the french in a text box

words are arrange like this in the text file

yes,oui,

the,le

 

the found = line is where the error seem to be occuring

 

Dim English, French, As String 
Dim i, where As Integer 
Dim Fword(), Eword(), As String 
Dim found As Boolean 

English = TxtEnglish.Text 
Fword = English.Split(" "c) 

For i = 0 To 30 
Do While ((Not found) And (where < rm.Length)) 
found = (Eword(i)) = rm(where, 0) 
where = where + 1 
Loop 
where = where - 1 
Fword(i) = rm(where, 1) 

Next 

TxtFrench.Text = Join(Fword, " ")

 

thanks guys

Edited by divil
  • *Experts*
Posted

What error are you getting?

 

It looks like your code structure is a little off. Perhaps you could explain

exactly how your code is meant to work (what is rm?) and we

could help you structure it better.

Posted

its a two dimensional array. the words have been placed in a text file in that format (yes, oui,at).

what i want o do is type the a sentence which contains the english word a display the translation in another language in this case french.

 

dim rm(30,3) as string

Dim English, French, As String

Dim i, where As Integer

Dim Fword(), Eword(), As String

Dim found As Boolean

 

English = TxtEnglish.Text

Fword = English.Split(" "c)

 

For i = 0 To 30

Do While ((Not found) And (where < rm.Length))

found = (Eword(i)) = rm(where, 0)

where = where + 1

Loop

where = where - 1

Fword(i) = rm(where, 1)

 

Next

 

TxtFrench.Text = Join(Fword," ")

  • *Experts*
Posted

It looks like you're never giving EWord any subscripts; you declare

it as Eword() (so you need to use Redim to dynamically size/initialize

it), but you never assign anything to it; you just get data out of it.

 

Perhaps when you say Fword = English.Split(...) you really mean

Eword = ...?

 

Also, you are going to need to give Fword an upper-bound. From the

way the code works, I'd say you could just change the declare from

Dim Fword() ... to Dim Fword(30) ...

  • *Experts*
Posted
Ok, try this:
dim rm(30,3) as string
Dim English, French, As String 
Dim i, where As Integer 
Dim Fword(30), Eword() As String 
Dim found As Boolean 

English = TxtEnglish.Text 
Eword = English.Split(" "c) 

For i = 0 To 30 
 Do While ((Not found) And (where < rm.Length)) 
   found = (Eword(i)) = rm(where, 0) 
   where = where + 1 
 Loop 
 where = where - 1 
 Fword(i) = rm(where, 1) 
Next 

TxtFrench.Text = Join(Fword," ")

  • *Experts*
Posted

It means you're trying to access an array element that is not in

the array (for example, accessing myArray(100) when myArray only

has 20 elements). I think there is a major flaw in your logic. Your

code would only work if the user typed 30 words or more in the

txtEnglish textbox. I'm sorry I can't really help you more, but I don't

totally know what your problem is. :-\

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...