R
ryguy7272
I am trying to understand some code that I found online. Basically, this will
populate a ListBox with random strings. Here is the code:
Protected Sub PopulateButton_Click(ByVal sender As Object, _
ByVal e As System.EventArgs)
Dim wordLen As Integer
Dim NWords As Integer = 9999
Dim rnd As System.Random
rnd = New System.Random()
Dim rndChar As Char
Dim thisWord As String
Dim i, j As Integer
For i = 0 To NWords
wordLen = CInt(rnd.NextDouble * 20 + 1)
thisWord = “â€
For j = 0 To wordLen
rndchar = Chr(65 + CInt(rnd.Next, 25))
thisWord = thisWord & rndChar
Next
ListBox1.Items.Add(thisWord)
Next
End Sub
I can’t get this running and I can understand how to resolve the error.
Error mssg:
Argument ‘CharCode’ must be with the range of -32768 to 65535
Can someone please explain what is wrong?
Thanks!
Ryan--
populate a ListBox with random strings. Here is the code:
Protected Sub PopulateButton_Click(ByVal sender As Object, _
ByVal e As System.EventArgs)
Dim wordLen As Integer
Dim NWords As Integer = 9999
Dim rnd As System.Random
rnd = New System.Random()
Dim rndChar As Char
Dim thisWord As String
Dim i, j As Integer
For i = 0 To NWords
wordLen = CInt(rnd.NextDouble * 20 + 1)
thisWord = “â€
For j = 0 To wordLen
rndchar = Chr(65 + CInt(rnd.Next, 25))
thisWord = thisWord & rndChar
Next
ListBox1.Items.Add(thisWord)
Next
End Sub
I can’t get this running and I can understand how to resolve the error.
Error mssg:
Argument ‘CharCode’ must be with the range of -32768 to 65535
Can someone please explain what is wrong?
Thanks!
Ryan--