I try to generate 10 random integers and store it in an array(9). Then I split the array into half by converting it into string. My code can compile but it sometimes work and most time cannot work. I don't know what is the problem....
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Randomize()
Dim rand As New Random
Dim array(9) As String
Dim X As String
Dim Y As String
Dim i As Integer
For i = 0 To 9
array(i) = rand.Next
i = i + 1
Next
Dim HiOrder As String = array(0).Substring(0, 5)
Dim LoOrder As String = array(0).Substring(5, 5)
X = 1.3 + (HiOrder * ((2.4 - 1.3) / ((10 ^ 5) - 1)))
Y = 3.4 + (LoOrder * ((4.7 - 3.4) / ((10 ^ 5) - 1)))
ListBox1.Items.Add(array(0))
ListBox1.Items.Add(HiOrder)
ListBox1.Items.Add(LoOrder)
ListBox1.Items.Add("X = " & X)
ListBox1.Items.Add("Y = " & Y)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
Can help me with this??? I can't seem to get it to run every time....