VB projects - Coffee Machine
Description: in-depth coverage of coffee-brewing process
Minimum requirements: VB5
Download: source code
Screenshot:

Project: Standard EXE
Controls: fm (Frame), picProcessor (PictureBox), picOutput (PictureBox), picGlass (PictureBox), cmdDrink (CommandButton, Index = 0), cmdDrink (CommandButton, Index = 1), cmdDrink (CommandButton, Index = 2), cmdDrink (CommandButton, Index = 3), lbl (Label)
Code:
Option Explicit
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Sub cmdDrink_Click(Index As Integer)
Dim n As Double
Dim x As Integer: Dim y As Integer
Dim x1 As Integer: Dim y2 As Integer
EnableButtons False
n = GetTickCount
lbl = "Processing the drink..."
x = fm.Left: y = fm.Top
While GetTickCount - n < 2000
Randomize
fm.Left = x + Int((20 * Rnd) + 1) - 10
Randomize
fm.Top = y + Int((20 * Rnd) + 1) - 10
Randomize
picProcessor.BackColor = QBColor(Rnd * 15)
frmMain.Refresh
DoEvents
Wend
fm.Left = x: fm.Top = y
picProcessor.BackColor = &HFF8080
While picGlass.Top < 30
picGlass.Top = picGlass.Top + 1
frmMain.Refresh
For x = 0 To 32000
Next
Wend
While picGlass.Left < picOutput.Width - picGlass.Width - 30
picGlass.Left = picGlass.Left + 1
frmMain.Refresh
For x = 0 To 32000
Next
Wend
lbl = "Take the drink"
n = GetTickCount
While GetTickCount - n < 2000
DoEvents
Wend
picGlass.Top = -700
picGlass.Left = 0
lbl = "Ready for use"
EnableButtons True
End Sub
Private Sub Form_Terminate()
End
End Sub
Private Sub Form_Unload(Cancel As Integer)
End
End Sub
Private Sub EnableButtons(b As Boolean)
cmdDrink(0).Enabled = b
cmdDrink(1).Enabled = b
cmdDrink(2).Enabled = b
cmdDrink(3).Enabled = b
End Sub
|