Dim varDie1Value As Single Option Explicit Dim n As Integer Dim BaseAddress As Integer Private Declare Function Inp Lib "inpout32.dll" _ Alias "Inp32" (ByVal PortAddress As Integer) As Integer Private Declare Sub Out Lib "inpout32.dll" _ Alias "Out32" (ByVal PortAddress As Integer, ByVal Value As Integer) Private Function parallelput(n As Integer) Out BaseAddress, n End Function Private Function parallelget() parallelget = (Inp(BaseAddress + 1) Xor &H90) End Function Private Sub Delay(n As Single) Dim Start Dim Check Start = Timer Do Until Check >= Start + n * 0.001 Check = Timer Loop End Sub Public Function controlput(n As Integer) Out (BaseAddress + 2), n Xor &HB End Function Public Function controlget() controlget = (Inp(BaseAddress + 2) Xor &HB) End Function Private Sub Form_Load() BaseAddress = &H378 'Go to Control panel to find the address End Sub Private Sub Timer1_Timer() n = n + 1 If n Mod 2 = 0 Then parallelput (1) Else parallelput (0) End If End Sub Private Sub Timer2_Timer() parallelput (2) End Sub Private Sub cmdRoll_Click() Randomize varDie1Value = 1 + Int(Rnd * 6) If varDie1Value = 1 Then shpDie1Dot1.Visible = False shpDie1Dot2.Visible = False shpDie1Dot3.Visible = False shpDie1Dot4.Visible = False shpDie1Dot5.Visible = False shpDie1Dot6.Visible = False shpDie1Dot7.Visible = True parallelput (64) ElseIf varDie1Value = 2 Then shpDie1Dot1.Visible = False shpDie1Dot2.Visible = False shpDie1Dot3.Visible = True shpDie1Dot4.Visible = True shpDie1Dot5.Visible = False shpDie1Dot6.Visible = False shpDie1Dot7.Visible = False parallelput (4 + 8) ElseIf varDie1Value = 3 Then shpDie1Dot1.Visible = False shpDie1Dot2.Visible = False shpDie1Dot3.Visible = True shpDie1Dot4.Visible = True shpDie1Dot5.Visible = False shpDie1Dot6.Visible = False shpDie1Dot7.Visible = True parallelput (4 + 8 + 64) ElseIf varDie1Value = 4 Then shpDie1Dot1.Visible = True shpDie1Dot2.Visible = False shpDie1Dot3.Visible = True shpDie1Dot4.Visible = True shpDie1Dot5.Visible = False shpDie1Dot6.Visible = True shpDie1Dot7.Visible = False parallelput (1 + 4 + 8 + 32) ElseIf varDie1Value = 5 Then shpDie1Dot1.Visible = True shpDie1Dot2.Visible = False shpDie1Dot3.Visible = True shpDie1Dot4.Visible = True shpDie1Dot5.Visible = False shpDie1Dot6.Visible = True shpDie1Dot7.Visible = True parallelput (1 + 4 + 8 + 32 + 64) ElseIf varDie1Value = 6 Then shpDie1Dot1.Visible = True shpDie1Dot2.Visible = True shpDie1Dot3.Visible = True shpDie1Dot4.Visible = True shpDie1Dot5.Visible = True shpDie1Dot6.Visible = True shpDie1Dot7.Visible = False parallelput (1 + 2 + 4 + 8 + 16 + 32) End If End Sub