I am quite puzzled here. I have a program inwhich when the user clicks on the command button, a random line should appear but only once.
I am storing each line with different variables.
Right now i have the random line coming up but it is repeating itself.
For instance, when i click on the button, line 1 appear, then line 4, and them line 1 again. How can i stop the line 1 to show again?
Function LoadNewQuestion() As String 'To lad a phrase
Dim ThisNewQuestion As String
Dim LoadedQuestionArray(10) As String
Dim QuestionCount As Integer = 0
dim mycount2 as string
FileOpen(1, "G:\Qu.txt", OpenMode.Input) 'open the file
While Not EOF(1) 'end of file
QuestionCount += 1
LoadedQuestionArray(QuestionCount) = (LineInput(1))
'the phrase is a random loaded phrase
FileClose(1) 'close file
ThisNewQuestion = LoadedQuestionArray(RandomNum(QuestionCount))
mycount2 = LoadedQuestionArray(RandomNum(QuestionCount - 1))
If mycount2 = ThisNewQuestion Then
Else : Label1.Text = ThisNewQuestion
Return ThisNewQuestion 'returning the function
Function RandomNum(ByVal maxnum As Integer) As Integer
Return Math.Ceiling(Rnd() * maxnum)
an error say bad file name or number
Edited 6 Years Ago by __avd: For easy readability, always wrap programming code within posts in [code] (code blocks)
Dim lines As List(Of String) = System.IO.File.ReadAllLines("c:\xyz\file.txt").ToList()
Dim rnd As New Random
Dim ind As Integer
While (lines.Count <> 0)
ind = rnd.Next(0, lines.Count)
Need some help with this Array. I am trying to get the sum of the even numbers and the sum of the odd numbers using a for each loop. I know the answers to what I am trying to achive are sum of even = 84 and the sum of ...
I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...