Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27246

generate random number from a selected item in a combo box

$
0
0
i am trying to generate 3, 7 or 12 random numbers when i select either small, medium, or large consectively from a combo box and then insert those random numbers into a list box. I keep getting this error: Variable 'strSmall' is used before it has been assigned a value. A null reference exception could result at runtime. What does this mean because my code looks like this
Dim rand As New Random
Dim r As Integer
Dim i As Integer
Dim strSmall As String
Dim strMedium As String
Dim strLarge As String

For i = 1 To 3
r = rand.next()
If strSmall = cbxSize.SelectedItem.ToString Then
lbxNumbersGenerated.Items.Add(r.ToString)

End If

Next i

End Sub
End Class

I know the code isn't completely done but i am just trying to figure out how to do it with small selected. I would appreciate the help.

Viewing all articles
Browse latest Browse all 27246

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>