[B]
HI ,I have this code:
the user choose item from the list (ex-"Colors") , and pressed button
the program generate a line from that text file which contains 2 word each like this file:
RED adom
Yellow zahov
white lavan
Green yarok
etc..
(the two words suppose to be with different languages).and displays the first word in textbox1, the user enter a word in textbox2 , and if it's the same as word2 it gives him a point.
THE CODE:
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If ListBox1.SelectedIndex() Then Bk: If TextBox2.Text = String.Empty Then Dim num As New Random Dim lines As String() = File.ReadAllLines("D:\Words\" & ListBox1.SelectedItem & ".txt", FileEncoding) nextrnd: Dim Line As String = lines(Integer.Parse(num.Next(0, UBound(lines) + 1))) Dim Pos As Integer = Line.IndexOf(" ") Dim Spted = Split(Was, ",") If UBound(Spted) >= UBound(lines) + 1 Then Dim RightA = (Label9.Text / (Int(Label9.Text) + Int(Label10.Text))) Dim Grade = (RightA * 100) MsgBox("You Finished this test!" & vbCrLf & "Your Grade is: " & Int(Grade), MsgBoxStyle.Information, "Done!") Exit Sub End If If InStr(Was, "," & Line.Substring(0, Pos)) Then GoTo NextRnd TextBox1.Text = Line.Substring(0, Pos) strAnswer = Line.Substring(Pos + 1, Line.Length - Pos - 1) Else If TextBox2.Text = strAnswer Then '' MessageBox.Show("That is Correct!", "Correct", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) Label3.Text = "RIGHT!" Label3.ForeColor = Color.Green Label9.Text += 1 Else '' MessageBox.Show("I am Sorry, that answer is not correct!", "Incorrect", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) Label3.Text = "WRONG!" Label3.ForeColor = Color.Red Label10.Text += 1 End If Label5.Text = TextBox1.Text Label4.Text = strAnswer Was &= "," & TextBox1.Text TextBox2.Text = String.Empty : GoTo Bk End If End If END sub
there are two problems with this code:
1. if I press on an item (file) in the listbox and it contains 2 words
(ex-"light colors") , it doesn't generate the words into the textbox.
2.only one or two cells in the listbox function OK .. but item1 and 2 and even more aren't function.
PLEASE YOUR HELP ...![]()




Reply With Quote