Vb 2010 Hangman Code

Submitted by: Submitted by

Views: 510

Words: 764

Pages: 4

Category: Science and Technology

Date Submitted: 04/26/2012 04:57 AM

Report This Essay

Imports System.IO

Public Class Form1

Dim i As Integer

Dim wrong As Integer = 0

Dim pen As New Pen(Color.Black, 7)

Dim pen2 As New Pen(Color.Black, 3)

' Create the brush object to

Dim brushBlack As New SolidBrush(Color.Black)

Dim brushWhite As New SolidBrush(Color.White)

Dim wordLabel(15) As Control

Dim randomNumber As Integer

Dim randomWord As String

Dim randomWords As New List(Of String)

Dim wordLength As Integer = 0

Dim lettersUsed As String = "?"

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim infile As StreamReader = New StreamReader("Words.txt")

Do While infile.Peek -1

randomWords.Add(CStr(infile.ReadLine()))

Loop

infile.Close()

End Sub

'Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove

' Label2.Text = "X = " & e.X & vbCrLf

' Label2.Text = Label2.Text & "Y = " & e.Y

'End Sub

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint

Me.CreateGraphics.DrawLine(pen, 675, 125, 695, 100)

Me.CreateGraphics.DrawLine(pen, 525, 100, 700, 100)

Me.CreateGraphics.DrawLine(pen, 675, 100, 675, 400)

Me.CreateGraphics.FillRectangle(brushBlack, 500, 400, 200, 40)

Me.CreateGraphics.DrawLine(pen2, 530, 100, 530, 150)

End Sub

Private Sub btnCheck_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCheck.Click

Dim found As Boolean = False

Dim i As Integer

If wordLength 0 Then

If tbCheck.Text "" Then

If lettersUsed.Contains(tbCheck.Text) Then

MessageBox.Show("You have already used this letter, choose another one.")

tbCheck.Text = ""

Else...