vb类随机数

时间:2011-11-07 18:38:47

标签: vb.net random

我正在尝试进行各种扑克游戏。我正在尝试学习vb课程。这是我的班级代码

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

这将是表格代码。

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

我的问题是为什么calc()总是为H11和H12返回0?我不能在课堂上制作一个随机的实例吗?

1 个答案:

答案 0 :(得分:3)

您从未调用Calc()方法。

相关问题