Login        
 
   
Nederlands English
 






Roll the Dice
 
VB.NET explanation

In order to make an easy random dice you can use Visual Web Developer Express with the next code. All you have to do is to place 6 images and a button in the form.

 
CodePrint
Partial Class _Default
    Inherits System.Web.UI.Page
    Dim i, getal As Integer
    Dim j As Double

    Public Sub visibles()
        Image1.Visible = False
        Image2.Visible = False
        Image3.Visible = False
        Image4.Visible = False
        Image5.Visible = False
        Image6.Visible = False
    End Sub

    Public Sub roll()
        visibles()
        i = 6
        j = Rnd()
        getal = Decimal.Round(i * j)
        If getal = 1 Then
            Image1.Visible = True
        End If
        If getal = 2 Then
            Image2.Visible = True
        End If
        If getal = 3 Then
            Image3.Visible = True
        End If
        If getal = 4 Then
            Image4.Visible = True
        End If
        If getal = 5 Then
            Image5.Visible = True
        End If
        If getal = 6 Then
            Image6.Visible = True
        End If
        If getal = 0 Then
            Try
                roll()
            Catch
            End Try
        End If
    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        roll()
    End Sub
End Class
  HTML 4.01 Code
  ASCII Code
 
 

Links
 

  © Sappy.nl by Frank van Rooijen
   
website statistics