atrueresistance
atrueresistance

Reputation: 1368

vb Class Random number

I am trying to make a poker game of sorts. I'm trying to learn vb classes. Here is my class code

Friend Class CalcCards
    Dim random As New Random()
    Private mH11 As Integer = 0
    Private mH12 As Integer = 0

    Public ReadOnly Property H11() As Integer
        Get
            H11 = mH11
        End Get
    End Property
    Public ReadOnly Property H12() As Integer
        Get
            H12 = mH12
        End Get
    End Property

    Public Sub Calc()
        Dim count As Integer = 52
        Dim intArr(51) As Integer
        Dim intshuffle(51) As Integer
        For i = 0 To 51
            intArr(i) = i
        Next

        mH11 = intArr(Random.Next(0, 51))
        mH12 = intArr(Random.Next(0, 51))
End Sub

This would be the form code.

    picH11.Image = ImageList1.Images(calc.H11)
    picH12.Image = ImageList1.Images(calc.H12)

My question is why does calc() always return 0 for H11 and H12? Can i not make an instance of random in a class?

Upvotes: 0

Views: 305

Answers (1)

SLaks
SLaks

Reputation: 888223

You never called the Calc() method.

Upvotes: 3

Related Questions