What's Here?
- Members: 149,624
- Replies: 506,753
- Topics: 79,851
- Snippets: 2,666
- Tutorials: 706
- Total Online: 1,986
- Members: 72
- Guests: 1,914
|
The bare bones of a childrens spelling game, display an image and lets the user spell the word. The only button is to exit the game
|
Submitted By: KeyWiz
|
|
Rating:
 
|
|
Views: 4,031 |
Language: Visual Basic
|
|
Last Modified: October 26, 2006 |
Instructions: Create a form with 1 picturebox, 1 textbox and 1 button
create a cow image and put it at
c:\My Images\Cow.bmp
copy and paste this code to the form (remoe the existing Form_Load procedure)
|
Snippet
[code]
Option Explicit
Public thisImage As String
Public thisWord As String
Public correctAnswers As Integer
Public msgOK
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Form_Load()
GetNextPicture
End Sub
Private Sub GetNextPicture()
'look up your next image
' there are many ways to do this, I can't do it all for you
' I will use only 1 image "c:\My Images\Cow.bmp"
thisImage = "c:\My Images\Cow.bmp"
thisWord = "Cow"
Text1.Text = "" ' empty textbox
'display your image
Picture1.Picture = LoadPicture(thisImage)
Picture1.Refresh
End Sub
Private Sub Form_Unload(Cancel As Integer)
Close All ' close all datasources
End ' exit program
End Sub
Private Sub Text1_Change()
If Text1.Text = LCase(thisWord) Then
msgOK = MsgBox("Thats Right!!!!", vbOKOnly)
correctAnswers = correctAnswers + 1
If correctAnswers >= 5 Then
msgOK = MsgBox("Fantasic! you are done!", vbOKOnly)
Unload Me ' call closing routine (same as clicking X in form corner)
End If
GetNextPicture
Else
' if user types two letter more than word length
If Len(Text1.Text) > (Len(thisWord) + 2) Then
msgOK = MsgBox("I'm sorry, try again", vbOKOnly)
Text1.Text = ""
End If
End If
End Sub
[code]
Copy & Paste
|
|
|
Be Social
Reference Sheets
Bye Bye Ads
Monthly Drawing
Top Contributors
Top 10 Kudos This Month
|