Langsung ke konten utama

Random Numpad Visual Basic.NET Program

 

Here I give you the source code to make a shuffle number like image above(random numpad).
IDE: Microsoft Visual Studio
Programming Language: VB.NET
First, you open your visual studio and create new project. Then, put 9 Buttons into your form and type this code below to your vb file project.

Public Class RandomNumpad
    Private Sub RandomNumpad_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim temp, index As String
        Dim Buttons() As Control = {Button1, Button2, Button3, Button4, Button5, Button6, Button7, Button8, Button9}
        Dim Rand As New Random
        For i As Integer = 0 To 8
            index = Rand.Next(1, 9)
            temp = Buttons(i).Text
            Buttons(i).Text = Buttons(index).Text
            Buttons(index).Text = temp
        Next
    End Sub
End Class