ust like a few others, i was assigned a Hangman project for VB.NET!!!
Yea so this is wat we have to do
-----read a word from a text box - DONE
-----when play is clicked, the word is read and the number of letters is replaced with an underscore (_ ) - DONE
check if the letter clicked is in the word -NOT DONE HAS TO BE A FUNCTION! - so that all u have to do is call the function for each letter
display the letter if it is found- NOT DONE also a function
each miss should have a part of the man be built - NOT DONE, should be a function
please somebody help me, i have till sunday to finish this, i've been trying and trying, and i'm still lost....
here is my code so far... please help me, i'm seriosly desperate, its realy messed up, dont know wats wrong nor how to fix it
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents btna As System.Windows.Forms.Button
Friend WithEvents btnm As System.Windows.Forms.Button
Friend WithEvents btnl As System.Windows.Forms.Button
Friend WithEvents btnk As System.Windows.Forms.Button
Friend WithEvents btnj As System.Windows.Forms.Button
Friend WithEvents btni As System.Windows.Forms.Button
Friend WithEvents btng As System.Windows.Forms.Button
Friend WithEvents btnf As System.Windows.Forms.Button
Friend WithEvents btne As System.Windows.Forms.Button
Friend WithEvents btnd As System.Windows.Forms.Button
Friend WithEvents btnc As System.Windows.Forms.Button
Friend WithEvents btnb As System.Windows.Forms.Button
Friend WithEvents btnu As System.Windows.Forms.Button
Friend WithEvents btnt As System.Windows.Forms.Button
Friend WithEvents btns As System.Windows.Forms.Button
Friend WithEvents btnr As System.Windows.Forms.Button
Friend WithEvents btnq As System.Windows.Forms.Button
Friend WithEvents btnp As System.Windows.Forms.Button
Friend WithEvents btno As System.Windows.Forms.Button
Friend WithEvents btnn As System.Windows.Forms.Button
Friend WithEvents btny As System.Windows.Forms.Button
Friend WithEvents btnx As System.Windows.Forms.Button
Friend WithEvents btnw As System.Windows.Forms.Button
Friend WithEvents btnv As System.Windows.Forms.Button
Friend WithEvents btnz As System.Windows.Forms.Button
Friend WithEvents btnh As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button()
Me.Label1 = New System.Windows.Forms.Label()
Me.Button2 = New System.Windows.Forms.Button()
Me.btna = New System.Windows.Forms.Button()
Me.btnm = New System.Windows.Forms.Button()
Me.btnl = New System.Windows.Forms.Button()
Me.btnk = New System.Windows.Forms.Button()
Me.btnj = New System.Windows.Forms.Button()
Me.btni = New System.Windows.Forms.Button()
Me.btnh = New System.Windows.Forms.Button()
Me.btng = New System.Windows.Forms.Button()
Me.btnf = New System.Windows.Forms.Button()
Me.btne = New System.Windows.Forms.Button()
Me.btnd = New System.Windows.Forms.Button()
Me.btnc = New System.Windows.Forms.Button()
Me.btnb = New System.Windows.Forms.Button()
Me.btny = New System.Windows.Forms.Button()
Me.btnx = New System.Windows.Forms.Button()
Me.btnw = New System.Windows.Forms.Button()
Me.btnv = New System.Windows.Forms.Button()
Me.btnu = New System.Windows.Forms.Button()
Me.btnt = New System.Windows.Forms.Button()
Me.btns = New System.Windows.Forms.Button()
Me.btnr = New System.Windows.Forms.Button()
Me.btnq = New System.Windows.Forms.Button()
Me.btnp = New System.Windows.Forms.Button()
Me.btno = New System.Windows.Forms.Button()
Me.btnn = New System.Windows.Forms.Button()
Me.btnz = New System.Windows.Forms.Button()
Me.Label2 = New System.Windows.Forms.Label()
Me.Label3 = New System.Windows.Forms.Label()
Me.Label4 = New System.Windows.Forms.Label()
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(8, 200)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(80, 24)
Me.Button1.TabIndex = 0
Me.Button1.Text = "Start"
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(184, 80)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(232, 40)
Me.Label1.TabIndex = 1
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(8, 224)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(80, 24)
Me.Button2.TabIndex = 2
Me.Button2.Text = "Exit"
'
'btna
'
Me.btna.Location = New System.Drawing.Point(56, 256)
Me.btna.Name = "btna"
Me.btna.Size = New System.Drawing.Size(32, 32)
Me.btna.TabIndex = 3
Me.btna.Text = "A"
'
'btnm
'
Me.btnm.Location = New System.Drawing.Point(440, 256)
Me.btnm.Name = "btnm"
Me.btnm.Size = New System.Drawing.Size(32, 32)
Me.btnm.TabIndex = 4
Me.btnm.Text = "M"
'
'btnl
'
Me.btnl.Location = New System.Drawing.Point(408, 256)
Me.btnl.Name = "btnl"
Me.btnl.Size = New System.Drawing.Size(32, 32)
Me.btnl.TabIndex = 5
Me.btnl.Text = "L"
'
'btnk
'
Me.btnk.Location = New System.Drawing.Point(376, 256)
Me.btnk.Name = "btnk"
Me.btnk.Size = New System.Drawing.Size(32, 32)
Me.btnk.TabIndex = 6
Me.btnk.Text = "K"
'
'btnj
'
Me.btnj.Location = New System.Drawing.Point(344, 256)
Me.btnj.Name = "btnj"
Me.btnj.Size = New System.Drawing.Size(32, 32)
Me.btnj.TabIndex = 7
Me.btnj.Text = "J"
'
'btni
'
Me.btni.Location = New System.Drawing.Point(312, 256)
Me.btni.Name = "btni"
Me.btni.Size = New System.Drawing.Size(32, 32)
Me.btni.TabIndex = 8
Me.btni.Text = "I"
'
'btnh
'
Me.btnh.Location = New System.Drawing.Point(280, 256)
Me.btnh.Name = "btnh"
Me.btnh.Size = New System.Drawing.Size(32, 32)
Me.btnh.TabIndex = 9
Me.btnh.Text = "H"
'
'btng
'
Me.btng.Location = New System.Drawing.Point(248, 256)
Me.btng.Name = "btng"
Me.btng.Size = New System.Drawing.Size(32, 32)
Me.btng.TabIndex = 10
Me.btng.Text = "G"
'
'btnf
'
Me.btnf.Location = New System.Drawing.Point(216, 256)
Me.btnf.Name = "btnf"
Me.btnf.Size = New System.Drawing.Size(32, 32)
Me.btnf.TabIndex = 11
Me.btnf.Text = "F"
'
'btne
'
Me.btne.Location = New System.Drawing.Point(184, 256)
Me.btne.Name = "btne"
Me.btne.Size = New System.Drawing.Size(32, 32)
Me.btne.TabIndex = 12
Me.btne.Text = "E"
'
'btnd
'
Me.btnd.Location = New System.Drawing.Point(152, 256)
Me.btnd.Name = "btnd"
Me.btnd.Size = New System.Drawing.Size(32, 32)
Me.btnd.TabIndex = 13
Me.btnd.Text = "D"
'
'btnc
'
Me.btnc.Location = New System.Drawing.Point(120, 256)
Me.btnc.Name = "btnc"
Me.btnc.Size = New System.Drawing.Size(32, 32)
Me.btnc.TabIndex = 14
Me.btnc.Text = "C"
'
'btnb
'
Me.btnb.Location = New System.Drawing.Point(88, 256)
Me.btnb.Name = "btnb"
Me.btnb.Size = New System.Drawing.Size(32, 32)
Me.btnb.TabIndex = 15
Me.btnb.Text = "B"
'
'btny
'
Me.btny.Location = New System.Drawing.Point(408, 288)
Me.btny.Name = "btny"
Me.btny.Size = New System.Drawing.Size(32, 32)
Me.btny.TabIndex = 16
Me.btny.Text = "Y"
'
'btnx
'
Me.btnx.Location = New System.Drawing.Point(376, 288)
Me.btnx.Name = "btnx"
Me.btnx.Size = New System.Drawing.Size(32, 32)
Me.btnx.TabIndex = 17
Me.btnx.Text = "X"
'
'btnw
'
Me.btnw.Location = New System.Drawing.Point(344, 288)
Me.btnw.Name = "btnw"
Me.btnw.Size = New System.Drawing.Size(32, 32)
Me.btnw.TabIndex = 18
Me.btnw.Text = "W"
'
'btnv
'
Me.btnv.Location = New System.Drawing.Point(312, 288)
Me.btnv.Name = "btnv"
Me.btnv.Size = New System.Drawing.Size(32, 32)
Me.btnv.TabIndex = 19
Me.btnv.Text = "V"
'
'btnu
'
Me.btnu.Location = New System.Drawing.Point(280, 288)
Me.btnu.Name = "btnu"
Me.btnu.Size = New System.Drawing.Size(32, 32)
Me.btnu.TabIndex = 20
Me.btnu.Text = "U"
'
'btnt
'
Me.btnt.Location = New System.Drawing.Point(248, 288)
Me.btnt.Name = "btnt"
Me.btnt.Size = New System.Drawing.Size(32, 32)
Me.btnt.TabIndex = 21
Me.btnt.Text = "T"
'
'btns
'
Me.btns.Location = New System.Drawing.Point(216, 288)
Me.btns.Name = "btns"
Me.btns.Size = New System.Drawing.Size(32, 32)
Me.btns.TabIndex = 22
Me.btns.Text = "S"
'
'btnr
'
Me.btnr.Location = New System.Drawing.Point(184, 288)
Me.btnr.Name = "btnr"
Me.btnr.Size = New System.Drawing.Size(32, 32)
Me.btnr.TabIndex = 23
Me.btnr.Text = "R"
'
'btnq
'
Me.btnq.Location = New System.Drawing.Point(152, 288)
Me.btnq.Name = "btnq"
Me.btnq.Size = New System.Drawing.Size(32, 32)
Me.btnq.TabIndex = 24
Me.btnq.Text = "Q"
'
'btnp
'
Me.btnp.Location = New System.Drawing.Point(120, 288)
Me.btnp.Name = "btnp"
Me.btnp.Size = New System.Drawing.Size(32, 32)
Me.btnp.TabIndex = 25
Me.btnp.Text = "P"
'
'btno
'
Me.btno.Location = New System.Drawing.Point(88, 288)
Me.btno.Name = "btno"
Me.btno.Size = New System.Drawing.Size(32, 32)
Me.btno.TabIndex = 26
Me.btno.Text = "O"
'
'btnn
'
Me.btnn.Location = New System.Drawing.Point(56, 288)
Me.btnn.Name = "btnn"
Me.btnn.Size = New System.Drawing.Size(32, 32)
Me.btnn.TabIndex = 27
Me.btnn.Text = "N"
'
'btnz
'
Me.btnz.Location = New System.Drawing.Point(440, 288)
Me.btnz.Name = "btnz"
Me.btnz.Size = New System.Drawing.Size(32, 32)
Me.btnz.TabIndex = 29
Me.btnz.Text = "Z"
'
'Label2
'
Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 26.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label2.Location = New System.Drawing.Point(0, 48)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(144, 40)
Me.Label2.TabIndex = 30
Me.Label2.Text = "Win:"
'
'Label3
'
Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 26.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label3.Location = New System.Drawing.Point(0, 88)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(144, 40)
Me.Label3.TabIndex = 31
Me.Label3.Text = "Loss:"
'
'Label4
'
Me.Label4.Font = New System.Drawing.Font("Microsoft Sans Serif", 26.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label4.Location = New System.Drawing.Point(0, 128)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(144, 40)
Me.Label4.TabIndex = 32
Me.Label4.Text = "Left:"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(512, 358)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label4, Me.Label3, Me.Label2, Me.btnz, Me.btnn, Me.btno, Me.btnp, Me.btnq, Me.btnr, Me.btns, Me.btnt, Me.btnu, Me.btnv, Me.btnw, Me.btnx, Me.btny, Me.btnb, Me.btnc, Me.btnd, Me.btne, Me.btnf, Me.btng, Me.btnh, Me.btni, Me.btnj, Me.btnk, Me.btnl, Me.btnm, Me.btna, Me.Button2, Me.Label1, Me.Button1})
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Dim word As String
Dim counter As Integer
Dim length As Decimal
Dim display As String
Dim place As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
word = GetNewWord("mm.txt")
enable()
Label1.Text = underscore(word.Length, "")
End Sub
Private Function underscore(ByVal wordlength As Integer, ByVal undscore As String) As String
For wordlength = 0 To wordlength - 1
undscore += "_ "
Next
Return undscore
End Function
Private Function check(ByVal letter As String, ByVal word1 As String, ByVal total As String, ByVal one As String, ByVal two As String)
place = word.IndexOf(letter)
If place = 0 Then
word1 = Label1.Text
one = word1.Substring(place)
total = letter + " " + one
Return total
End If
If place > 0 Then
word1 = Label1.Text
two = word1.Substring(0, place)
one = word1.Substring(place)
total = one + " " + letter + " " + two
Return total
Return Label1.Text - 1
End If
End Function
Private Function enable()
btna.Enabled = True
btnb.Enabled = True
btnc.Enabled = True
btnd.Enabled = True
btne.Enabled = True
btnf.Enabled = True
btng.Enabled = True
btnh.Enabled = True
btni.Enabled = True
btnj.Enabled = True
btnk.Enabled = True
btnl.Enabled = True
btnm.Enabled = True
btnn.Enabled = True
btno.Enabled = True
btnp.Enabled = True
btnq.Enabled = True
btnr.Enabled = True
btns.Enabled = True
btnt.Enabled = True
btnu.Enabled = True
btnv.Enabled = True
btnw.Enabled = True
btnx.Enabled = True
btny.Enabled = True
btnz.Enabled = True
End Function
'----------------------------------------------------LETTER CLICK EVENTS--------------------------------------------------------------------
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btna.Click
btna.Enabled = False
Label1.Text = check("a", "", "", "", "")
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnb.Click
btnb.Enabled = False
Label1.Text = check("b", "", "", "", "")
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnc.Click
btnc.Enabled = False
Label1.Text = check("b", "", "", "", "")
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnd.Click
btnd.Enabled = False
Label1.Text = check("d", "", "", "", "")
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btne.Click
Label1.Text = check("e", "", "", "", "")
btne.Enabled = False
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnf.Click
check("f", "", "", "", "")
btnf.Enabled = False
End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btng.Click
Label1.Text = check("g", "", "", "", "")
btng.Enabled = False
End Sub
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnh.Click
Label1.Text = check("h", "", "", "", "")
btnh.Enabled = False
End Sub
Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btni.Click
Label1.Text = check("i", "", "", "", "")
btni.Enabled = False
End Sub
Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnj.Click
Label1.Text = check("j", "", "", "", "")
btnj.Enabled = False
End Sub
Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnk.Click
Label1.Text = check("k", "", "", "", "")
btnk.Enabled = False
End Sub
Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnl.Click
Label1.Text = check("l", "", "", "", "")
btnl.Enabled = False
End Sub
Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnm.Click
Label1.Text = check("m", "", "", "", "")
btnm.Enabled = False
End Sub
Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnn.Click
Label1.Text = check("n", "", "", "", "")
btnn.Enabled = False
End Sub
Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btno.Click
Label1.Text = check("o", "", "", "", "")
btno.Enabled = False
End Sub
Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnp.Click
Label1.Text = check("p", "", "", "", "")
btnp.Enabled = False
End Sub
Private Sub Button19_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnq.Click
Label1.Text = check("q", "", "", "", "")
btnq.Enabled = False
End Sub
Private Sub Button20_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnr.Click
Label1.Text = check("r", "", "", "", "")
btnr.Enabled = False
End Sub
Private Sub Button21_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btns.Click
Label1.Text = check("s", "", "", "", "")
btns.Enabled = False
End Sub
Private Sub Button22_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnt.Click
Label1.Text = check("t", "", "", "", "")
btnt.Enabled = False
End Sub
Private Sub Button23_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnu.Click
Label1.Text = check("u", "", "", "", "")
btnu.Enabled = False
End Sub
Private Sub Button24_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnv.Click
Label1.Text = check("v", "", "", "", "")
btnv.Enabled = False
End Sub
Private Sub Button25_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnw.Click
Label1.Text = check("w", "", "", "", "")
btnw.Enabled = False
End Sub
Private Sub Button26_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnx.Click
Label1.Text = check("x", "", "", "", "")
btnx.Enabled = False
End Sub
Private Sub Button27_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btny.Click
Label1.Text = check("y", "", "", "", "")
btny.Enabled = False
End Sub
Private Sub Button28_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnz.Click
Label1.Text = check("z", "", "", "", "")
btnz.Enabled = False
End Sub
'--------------------------------------------------ABCDEFGHIJKLMNOPQRSTUVQXYZ-------------------------------------------------------------------
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
End Class