VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



A Simple Number Game

by Adupa Srinivas (1 Submission)
Category: Games
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sat 10th August 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

A Simple Number Game

Rate A Simple Number Game



Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long

Option Explicit
    Dim i As Integer
    Dim j As Integer
    Dim First As Integer
    Dim Last As Integer
    Dim X As Integer
    Dim Y As Integer
    Dim Sh As Long
    Dim Sh1 As Long
    
Private Sub Command1_Click(Index As Integer)
   On Error GoTo Srinivas
    If Command1(Index - 4).Caption = "" Then
        Command1(Index - 4).Caption = Command1(Index).Caption
        Command1(Index).Caption = ""
    ElseIf Command1(Index - 1).Caption = "" Then
        Command1(Index - 1).Caption = Command1(Index).Caption
        Command1(Index).Caption = ""
    ElseIf Command1(Index + 1).Caption = "" Then
        Command1(Index + 1).Caption = Command1(Index).Caption
        Command1(Index).Caption = ""
    ElseIf Command1(Index + 4).Caption = "" Then
        Command1(Index + 4).Caption = Command1(Index).Caption
        Command1(Index).Caption = ""
    End If
   Exit Sub
Srinivas:
    If (Index - 1) < 0 Then
        If Command1(Index + 4).Caption = "" Then
            Command1(Index + 4).Caption = Command1(Index).Caption
            Command1(Index).Caption = ""
        End If
        If Command1(Index + 1).Caption = "" Then
            Command1(Index + 1).Caption = Command1(Index).Caption
            Command1(Index).Caption = ""
        End If
    End If
     
    If (Index - 4) < 0 Then
       If (Index - 1) < 0 Then
           If Command1(Index + 4).Caption = "" Then
              Command1(Index + 4).Caption = Command1(Index).Caption
              Command1(Index).Caption = ""
           End If
           Exit Sub
       End If
  
        If Command1(Index - 1).Caption = "" Then
            Command1(Index - 1).Caption = Command1(Index).Caption
            Command1(Index).Caption = ""
        End If
        If Command1(Index + 1).Caption = "" Then
            Command1(Index + 1).Caption = Command1(Index).Caption
            Command1(Index).Caption = ""
        End If
        If Command1(Index + 4).Caption = "" Then
            Command1(Index + 4).Caption = Command1(Index).Caption
            Command1(Index).Caption = ""
        End If
    End If
End Sub

Private Sub Command2_Click()
    End
End Sub

Private Sub Form_Activate()
    Static arr(100) As Integer
    Randomize
    While Y < 15
srinu:      X = Rnd * Last
      For i = First To Last
        If X = arr(i) Then GoTo srinu
      Next i
      arr(j) = X
      j = j + 1
      Command1(Y).Caption = X
      Y = Y + 1
    Wend
End Sub

Private Sub Form_Load()
    First = 0
    Last = 15
Sh = CreateEllipticRgn(10, 10, 450, 300)
Sh1 = SetWindowRgn(Me.hWnd, Sh, True)
End Sub


Download this snippet    Add to My Saved Code

A Simple Number Game Comments

No comments have been posted about A Simple Number Game. Why not be the first to post a comment about A Simple Number Game.

Post your comment

Subject:
Message:
0/1000 characters