VB icon

Monkey Typist

Email
Submitted on: 1/23/2015 10:31:00 AM
By: Roy Goode (from psc cd)  
Level: Advanced
User Rating: By 3 Users
Compatibility: VB 5.0, VB 6.0
Views: 598
 
     This code is basically a random text generator that taps out random strings of characters. It is a Monkey Typist because sometimes it might just make sense! The idea is that you watch the text appear and then see if the 'Monkey' enters real words or even sentences!

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Monkey Typist
' Description:This code is basically a random text generator that taps out random strings of characters. It is a Monkey Typist because sometimes it might just make sense! The idea is that you watch the text appear and then see if the 'Monkey' enters real words or even sentences!
' By: Roy Goode (from psc cd)
'
' Inputs:The user is not required to input anything, just run the program and watch that monkey type!
'
' Assumes:1. Start a new Standard EXE project
' 2. Rename Form1 to frmMonkey
' 3. Put a text box onto the form and name it txtMonkey
' 4. Set the text box's 'MultiLine' property to True
' 5. Set the text box's 'ScrollBars' property to 2 - Vertical
' 6. Put a timer onto the form and name it tmrMonkey
' 7. Set the timer's 'Enabled' property to False
' 8. Copy this code into the form's class module
'**************************************

Option Explicit
Dim intOriginalRnd As Integer
Private Sub Form_Load()
Dim fntA As New StdFont
fntA.Name = "Tahoma"
fntA.Size = 8
Me.Width = 6225
txtMonkey.Font = fntA
txtMonkey.Text = ""
txtMonkey.Locked = True
tmrMonkey.Interval = 100
tmrMonkey.Enabled = True
End Sub
Private Sub Form_Resize()
tmrMonkey.Enabled = False
With frmMonkey
txtMonkey.Height = .ScaleHeight
txtMonkey.Width = .ScaleWidth
txtMonkey.Left = .ScaleLeft
txtMonkey.Top = .ScaleTop
If .WindowState = 0 Then
 .Left = (Screen.Width - .Width) / 2
 .Top = (Screen.Height - .Height) / 2
End If
End With
tmrMonkey.Enabled = True
End Sub
Private Sub tmrMonkey_Timer()
intOriginalRnd = Int(Rnd * 10)
Dim intRnd As Integer
Randomize
frmMonkey.Caption = "Monkey Typist - Click text to stop"
If intOriginalRnd < 1 Then
 intRnd = 32
ElseIf intOriginalRnd < 2 Then
 intRnd = Int(3 * Rnd + 44)
ElseIf intOriginalRnd < 6 Then
 intRnd = Int(26 * Rnd + 97)
ElseIf intOriginalRnd < 10 Then
 intRnd = Int(26 * Rnd + 65)
End If
frmMonkey.Caption = "Monkey Typist - Click text to stop - " & Chr(intRnd)
txtMonkey.Text = txtMonkey.Text & Chr(intRnd)
End Sub
Private Sub txtMonkey_Click()
If tmrMonkey.Enabled = True Then
 tmrMonkey.Enabled = False
 frmMonkey.Caption = "Monkey Typist - Click text to start"
Else
 tmrMonkey.Enabled = True
End If
End Sub


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.