hangman revised

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2004
Posts: 10
Reputation: weazel is an unknown quantity at this point 
Solved Threads: 0
weazel weazel is offline Offline
Newbie Poster

hangman revised

 
0
  #1
Dec 30th, 2004
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

  1. Public Class Form1
  2. Inherits System.Windows.Forms.Form
  3.  
  4. #Region " Windows Form Designer generated code "
  5.  
  6. Public Sub New()
  7. MyBase.New()
  8.  
  9. 'This call is required by the Windows Form Designer.
  10. InitializeComponent()
  11.  
  12. 'Add any initialization after the InitializeComponent() call
  13.  
  14. End Sub
  15.  
  16. 'Form overrides dispose to clean up the component list.
  17. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
  18. If disposing Then
  19. If Not (components Is Nothing) Then
  20. components.Dispose()
  21. End If
  22. End If
  23. MyBase.Dispose(disposing)
  24. End Sub
  25.  
  26. 'Required by the Windows Form Designer
  27. Private components As System.ComponentModel.IContainer
  28.  
  29. 'NOTE: The following procedure is required by the Windows Form Designer
  30. 'It can be modified using the Windows Form Designer.
  31. 'Do not modify it using the code editor.
  32. Friend WithEvents Button1 As System.Windows.Forms.Button
  33. Friend WithEvents Label1 As System.Windows.Forms.Label
  34. Friend WithEvents Button2 As System.Windows.Forms.Button
  35. Friend WithEvents Label2 As System.Windows.Forms.Label
  36. Friend WithEvents Label3 As System.Windows.Forms.Label
  37. Friend WithEvents Label4 As System.Windows.Forms.Label
  38. Friend WithEvents btna As System.Windows.Forms.Button
  39. Friend WithEvents btnm As System.Windows.Forms.Button
  40. Friend WithEvents btnl As System.Windows.Forms.Button
  41. Friend WithEvents btnk As System.Windows.Forms.Button
  42. Friend WithEvents btnj As System.Windows.Forms.Button
  43. Friend WithEvents btni As System.Windows.Forms.Button
  44. Friend WithEvents btng As System.Windows.Forms.Button
  45. Friend WithEvents btnf As System.Windows.Forms.Button
  46. Friend WithEvents btne As System.Windows.Forms.Button
  47. Friend WithEvents btnd As System.Windows.Forms.Button
  48. Friend WithEvents btnc As System.Windows.Forms.Button
  49. Friend WithEvents btnb As System.Windows.Forms.Button
  50. Friend WithEvents btnu As System.Windows.Forms.Button
  51. Friend WithEvents btnt As System.Windows.Forms.Button
  52. Friend WithEvents btns As System.Windows.Forms.Button
  53. Friend WithEvents btnr As System.Windows.Forms.Button
  54. Friend WithEvents btnq As System.Windows.Forms.Button
  55. Friend WithEvents btnp As System.Windows.Forms.Button
  56. Friend WithEvents btno As System.Windows.Forms.Button
  57. Friend WithEvents btnn As System.Windows.Forms.Button
  58. Friend WithEvents btny As System.Windows.Forms.Button
  59. Friend WithEvents btnx As System.Windows.Forms.Button
  60. Friend WithEvents btnw As System.Windows.Forms.Button
  61. Friend WithEvents btnv As System.Windows.Forms.Button
  62. Friend WithEvents btnz As System.Windows.Forms.Button
  63. Friend WithEvents btnh As System.Windows.Forms.Button
  64. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
  65. Me.Button1 = New System.Windows.Forms.Button()
  66. Me.Label1 = New System.Windows.Forms.Label()
  67. Me.Button2 = New System.Windows.Forms.Button()
  68. Me.btna = New System.Windows.Forms.Button()
  69. Me.btnm = New System.Windows.Forms.Button()
  70. Me.btnl = New System.Windows.Forms.Button()
  71. Me.btnk = New System.Windows.Forms.Button()
  72. Me.btnj = New System.Windows.Forms.Button()
  73. Me.btni = New System.Windows.Forms.Button()
  74. Me.btnh = New System.Windows.Forms.Button()
  75. Me.btng = New System.Windows.Forms.Button()
  76. Me.btnf = New System.Windows.Forms.Button()
  77. Me.btne = New System.Windows.Forms.Button()
  78. Me.btnd = New System.Windows.Forms.Button()
  79. Me.btnc = New System.Windows.Forms.Button()
  80. Me.btnb = New System.Windows.Forms.Button()
  81. Me.btny = New System.Windows.Forms.Button()
  82. Me.btnx = New System.Windows.Forms.Button()
  83. Me.btnw = New System.Windows.Forms.Button()
  84. Me.btnv = New System.Windows.Forms.Button()
  85. Me.btnu = New System.Windows.Forms.Button()
  86. Me.btnt = New System.Windows.Forms.Button()
  87. Me.btns = New System.Windows.Forms.Button()
  88. Me.btnr = New System.Windows.Forms.Button()
  89. Me.btnq = New System.Windows.Forms.Button()
  90. Me.btnp = New System.Windows.Forms.Button()
  91. Me.btno = New System.Windows.Forms.Button()
  92. Me.btnn = New System.Windows.Forms.Button()
  93. Me.btnz = New System.Windows.Forms.Button()
  94. Me.Label2 = New System.Windows.Forms.Label()
  95. Me.Label3 = New System.Windows.Forms.Label()
  96. Me.Label4 = New System.Windows.Forms.Label()
  97. Me.SuspendLayout()
  98. '
  99. 'Button1
  100. '
  101. Me.Button1.Location = New System.Drawing.Point(8, 200)
  102. Me.Button1.Name = "Button1"
  103. Me.Button1.Size = New System.Drawing.Size(80, 24)
  104. Me.Button1.TabIndex = 0
  105. Me.Button1.Text = "Start"
  106. '
  107. 'Label1
  108. '
  109. Me.Label1.Location = New System.Drawing.Point(184, 80)
  110. Me.Label1.Name = "Label1"
  111. Me.Label1.Size = New System.Drawing.Size(232, 40)
  112. Me.Label1.TabIndex = 1
  113. '
  114. 'Button2
  115. '
  116. Me.Button2.Location = New System.Drawing.Point(8, 224)
  117. Me.Button2.Name = "Button2"
  118. Me.Button2.Size = New System.Drawing.Size(80, 24)
  119. Me.Button2.TabIndex = 2
  120. Me.Button2.Text = "Exit"
  121. '
  122. 'btna
  123. '
  124. Me.btna.Location = New System.Drawing.Point(56, 256)
  125. Me.btna.Name = "btna"
  126. Me.btna.Size = New System.Drawing.Size(32, 32)
  127. Me.btna.TabIndex = 3
  128. Me.btna.Text = "A"
  129. '
  130. 'btnm
  131. '
  132. Me.btnm.Location = New System.Drawing.Point(440, 256)
  133. Me.btnm.Name = "btnm"
  134. Me.btnm.Size = New System.Drawing.Size(32, 32)
  135. Me.btnm.TabIndex = 4
  136. Me.btnm.Text = "M"
  137. '
  138. 'btnl
  139. '
  140. Me.btnl.Location = New System.Drawing.Point(408, 256)
  141. Me.btnl.Name = "btnl"
  142. Me.btnl.Size = New System.Drawing.Size(32, 32)
  143. Me.btnl.TabIndex = 5
  144. Me.btnl.Text = "L"
  145. '
  146. 'btnk
  147. '
  148. Me.btnk.Location = New System.Drawing.Point(376, 256)
  149. Me.btnk.Name = "btnk"
  150. Me.btnk.Size = New System.Drawing.Size(32, 32)
  151. Me.btnk.TabIndex = 6
  152. Me.btnk.Text = "K"
  153. '
  154. 'btnj
  155. '
  156. Me.btnj.Location = New System.Drawing.Point(344, 256)
  157. Me.btnj.Name = "btnj"
  158. Me.btnj.Size = New System.Drawing.Size(32, 32)
  159. Me.btnj.TabIndex = 7
  160. Me.btnj.Text = "J"
  161. '
  162. 'btni
  163. '
  164. Me.btni.Location = New System.Drawing.Point(312, 256)
  165. Me.btni.Name = "btni"
  166. Me.btni.Size = New System.Drawing.Size(32, 32)
  167. Me.btni.TabIndex = 8
  168. Me.btni.Text = "I"
  169. '
  170. 'btnh
  171. '
  172. Me.btnh.Location = New System.Drawing.Point(280, 256)
  173. Me.btnh.Name = "btnh"
  174. Me.btnh.Size = New System.Drawing.Size(32, 32)
  175. Me.btnh.TabIndex = 9
  176. Me.btnh.Text = "H"
  177. '
  178. 'btng
  179. '
  180. Me.btng.Location = New System.Drawing.Point(248, 256)
  181. Me.btng.Name = "btng"
  182. Me.btng.Size = New System.Drawing.Size(32, 32)
  183. Me.btng.TabIndex = 10
  184. Me.btng.Text = "G"
  185. '
  186. 'btnf
  187. '
  188. Me.btnf.Location = New System.Drawing.Point(216, 256)
  189. Me.btnf.Name = "btnf"
  190. Me.btnf.Size = New System.Drawing.Size(32, 32)
  191. Me.btnf.TabIndex = 11
  192. Me.btnf.Text = "F"
  193. '
  194. 'btne
  195. '
  196. Me.btne.Location = New System.Drawing.Point(184, 256)
  197. Me.btne.Name = "btne"
  198. Me.btne.Size = New System.Drawing.Size(32, 32)
  199. Me.btne.TabIndex = 12
  200. Me.btne.Text = "E"
  201. '
  202. 'btnd
  203. '
  204. Me.btnd.Location = New System.Drawing.Point(152, 256)
  205. Me.btnd.Name = "btnd"
  206. Me.btnd.Size = New System.Drawing.Size(32, 32)
  207. Me.btnd.TabIndex = 13
  208. Me.btnd.Text = "D"
  209. '
  210. 'btnc
  211. '
  212. Me.btnc.Location = New System.Drawing.Point(120, 256)
  213. Me.btnc.Name = "btnc"
  214. Me.btnc.Size = New System.Drawing.Size(32, 32)
  215. Me.btnc.TabIndex = 14
  216. Me.btnc.Text = "C"
  217. '
  218. 'btnb
  219. '
  220. Me.btnb.Location = New System.Drawing.Point(88, 256)
  221. Me.btnb.Name = "btnb"
  222. Me.btnb.Size = New System.Drawing.Size(32, 32)
  223. Me.btnb.TabIndex = 15
  224. Me.btnb.Text = "B"
  225. '
  226. 'btny
  227. '
  228. Me.btny.Location = New System.Drawing.Point(408, 288)
  229. Me.btny.Name = "btny"
  230. Me.btny.Size = New System.Drawing.Size(32, 32)
  231. Me.btny.TabIndex = 16
  232. Me.btny.Text = "Y"
  233. '
  234. 'btnx
  235. '
  236. Me.btnx.Location = New System.Drawing.Point(376, 288)
  237. Me.btnx.Name = "btnx"
  238. Me.btnx.Size = New System.Drawing.Size(32, 32)
  239. Me.btnx.TabIndex = 17
  240. Me.btnx.Text = "X"
  241. '
  242. 'btnw
  243. '
  244. Me.btnw.Location = New System.Drawing.Point(344, 288)
  245. Me.btnw.Name = "btnw"
  246. Me.btnw.Size = New System.Drawing.Size(32, 32)
  247. Me.btnw.TabIndex = 18
  248. Me.btnw.Text = "W"
  249. '
  250. 'btnv
  251. '
  252. Me.btnv.Location = New System.Drawing.Point(312, 288)
  253. Me.btnv.Name = "btnv"
  254. Me.btnv.Size = New System.Drawing.Size(32, 32)
  255. Me.btnv.TabIndex = 19
  256. Me.btnv.Text = "V"
  257. '
  258. 'btnu
  259. '
  260. Me.btnu.Location = New System.Drawing.Point(280, 288)
  261. Me.btnu.Name = "btnu"
  262. Me.btnu.Size = New System.Drawing.Size(32, 32)
  263. Me.btnu.TabIndex = 20
  264. Me.btnu.Text = "U"
  265. '
  266. 'btnt
  267. '
  268. Me.btnt.Location = New System.Drawing.Point(248, 288)
  269. Me.btnt.Name = "btnt"
  270. Me.btnt.Size = New System.Drawing.Size(32, 32)
  271. Me.btnt.TabIndex = 21
  272. Me.btnt.Text = "T"
  273. '
  274. 'btns
  275. '
  276. Me.btns.Location = New System.Drawing.Point(216, 288)
  277. Me.btns.Name = "btns"
  278. Me.btns.Size = New System.Drawing.Size(32, 32)
  279. Me.btns.TabIndex = 22
  280. Me.btns.Text = "S"
  281. '
  282. 'btnr
  283. '
  284. Me.btnr.Location = New System.Drawing.Point(184, 288)
  285. Me.btnr.Name = "btnr"
  286. Me.btnr.Size = New System.Drawing.Size(32, 32)
  287. Me.btnr.TabIndex = 23
  288. Me.btnr.Text = "R"
  289. '
  290. 'btnq
  291. '
  292. Me.btnq.Location = New System.Drawing.Point(152, 288)
  293. Me.btnq.Name = "btnq"
  294. Me.btnq.Size = New System.Drawing.Size(32, 32)
  295. Me.btnq.TabIndex = 24
  296. Me.btnq.Text = "Q"
  297. '
  298. 'btnp
  299. '
  300. Me.btnp.Location = New System.Drawing.Point(120, 288)
  301. Me.btnp.Name = "btnp"
  302. Me.btnp.Size = New System.Drawing.Size(32, 32)
  303. Me.btnp.TabIndex = 25
  304. Me.btnp.Text = "P"
  305. '
  306. 'btno
  307. '
  308. Me.btno.Location = New System.Drawing.Point(88, 288)
  309. Me.btno.Name = "btno"
  310. Me.btno.Size = New System.Drawing.Size(32, 32)
  311. Me.btno.TabIndex = 26
  312. Me.btno.Text = "O"
  313. '
  314. 'btnn
  315. '
  316. Me.btnn.Location = New System.Drawing.Point(56, 288)
  317. Me.btnn.Name = "btnn"
  318. Me.btnn.Size = New System.Drawing.Size(32, 32)
  319. Me.btnn.TabIndex = 27
  320. Me.btnn.Text = "N"
  321. '
  322. 'btnz
  323. '
  324. Me.btnz.Location = New System.Drawing.Point(440, 288)
  325. Me.btnz.Name = "btnz"
  326. Me.btnz.Size = New System.Drawing.Size(32, 32)
  327. Me.btnz.TabIndex = 29
  328. Me.btnz.Text = "Z"
  329. '
  330. 'Label2
  331. '
  332. Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 26.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  333. Me.Label2.Location = New System.Drawing.Point(0, 48)
  334. Me.Label2.Name = "Label2"
  335. Me.Label2.Size = New System.Drawing.Size(144, 40)
  336. Me.Label2.TabIndex = 30
  337. Me.Label2.Text = "Win:"
  338. '
  339. 'Label3
  340. '
  341. Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 26.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  342. Me.Label3.Location = New System.Drawing.Point(0, 88)
  343. Me.Label3.Name = "Label3"
  344. Me.Label3.Size = New System.Drawing.Size(144, 40)
  345. Me.Label3.TabIndex = 31
  346. Me.Label3.Text = "Loss:"
  347. '
  348. 'Label4
  349. '
  350. Me.Label4.Font = New System.Drawing.Font("Microsoft Sans Serif", 26.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  351. Me.Label4.Location = New System.Drawing.Point(0, 128)
  352. Me.Label4.Name = "Label4"
  353. Me.Label4.Size = New System.Drawing.Size(144, 40)
  354. Me.Label4.TabIndex = 32
  355. Me.Label4.Text = "Left:"
  356. '
  357. 'Form1
  358. '
  359. Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
  360. Me.ClientSize = New System.Drawing.Size(512, 358)
  361. 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})
  362. Me.Name = "Form1"
  363. Me.Text = "Form1"
  364. Me.ResumeLayout(False)
  365.  
  366. End Sub
  367.  
  368. #End Region
  369. Dim word As String
  370. Dim counter As Integer
  371. Dim length As Decimal
  372. Dim display As String
  373. Dim place As Integer
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  385. word = GetNewWord("mm.txt")
  386. enable()
  387. Label1.Text = underscore(word.Length, "")
  388.  
  389. End Sub
  390.  
  391. Private Function underscore(ByVal wordlength As Integer, ByVal undscore As String) As String
  392.  
  393. For wordlength = 0 To wordlength - 1
  394. undscore += "_ "
  395. Next
  396.  
  397. Return undscore
  398.  
  399.  
  400. End Function
  401.  
  402.  
  403. Private Function check(ByVal letter As String, ByVal word1 As String, ByVal total As String, ByVal one As String, ByVal two As String)
  404.  
  405. place = word.IndexOf(letter)
  406. If place = 0 Then
  407. word1 = Label1.Text
  408. one = word1.Substring(place)
  409.  
  410. total = letter + " " + one
  411. Return total
  412.  
  413. End If
  414.  
  415.  
  416. If place > 0 Then
  417. word1 = Label1.Text
  418. two = word1.Substring(0, place)
  419. one = word1.Substring(place)
  420. total = one + " " + letter + " " + two
  421. Return total
  422. Return Label1.Text - 1
  423.  
  424. End If
  425.  
  426.  
  427.  
  428. End Function
  429.  
  430.  
  431.  
  432. Private Function enable()
  433. btna.Enabled = True
  434. btnb.Enabled = True
  435. btnc.Enabled = True
  436. btnd.Enabled = True
  437. btne.Enabled = True
  438. btnf.Enabled = True
  439. btng.Enabled = True
  440. btnh.Enabled = True
  441. btni.Enabled = True
  442. btnj.Enabled = True
  443. btnk.Enabled = True
  444. btnl.Enabled = True
  445. btnm.Enabled = True
  446. btnn.Enabled = True
  447. btno.Enabled = True
  448. btnp.Enabled = True
  449. btnq.Enabled = True
  450. btnr.Enabled = True
  451. btns.Enabled = True
  452. btnt.Enabled = True
  453. btnu.Enabled = True
  454. btnv.Enabled = True
  455. btnw.Enabled = True
  456. btnx.Enabled = True
  457. btny.Enabled = True
  458. btnz.Enabled = True
  459. End Function
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470. '----------------------------------------------------LETTER CLICK EVENTS--------------------------------------------------------------------
  471. Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btna.Click
  472. btna.Enabled = False
  473. Label1.Text = check("a", "", "", "", "")
  474. End Sub
  475. Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnb.Click
  476. btnb.Enabled = False
  477. Label1.Text = check("b", "", "", "", "")
  478. End Sub
  479. Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnc.Click
  480. btnc.Enabled = False
  481. Label1.Text = check("b", "", "", "", "")
  482. End Sub
  483. Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnd.Click
  484. btnd.Enabled = False
  485. Label1.Text = check("d", "", "", "", "")
  486. End Sub
  487. Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btne.Click
  488. Label1.Text = check("e", "", "", "", "")
  489. btne.Enabled = False
  490. End Sub
  491. Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnf.Click
  492. check("f", "", "", "", "")
  493. btnf.Enabled = False
  494. End Sub
  495. Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btng.Click
  496. Label1.Text = check("g", "", "", "", "")
  497. btng.Enabled = False
  498. End Sub
  499. Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnh.Click
  500. Label1.Text = check("h", "", "", "", "")
  501. btnh.Enabled = False
  502. End Sub
  503. Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btni.Click
  504. Label1.Text = check("i", "", "", "", "")
  505. btni.Enabled = False
  506. End Sub
  507. Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnj.Click
  508. Label1.Text = check("j", "", "", "", "")
  509. btnj.Enabled = False
  510. End Sub
  511. Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnk.Click
  512. Label1.Text = check("k", "", "", "", "")
  513. btnk.Enabled = False
  514. End Sub
  515. Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnl.Click
  516. Label1.Text = check("l", "", "", "", "")
  517. btnl.Enabled = False
  518. End Sub
  519. Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnm.Click
  520. Label1.Text = check("m", "", "", "", "")
  521. btnm.Enabled = False
  522. End Sub
  523. Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnn.Click
  524. Label1.Text = check("n", "", "", "", "")
  525. btnn.Enabled = False
  526. End Sub
  527. Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btno.Click
  528. Label1.Text = check("o", "", "", "", "")
  529. btno.Enabled = False
  530. End Sub
  531. Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnp.Click
  532. Label1.Text = check("p", "", "", "", "")
  533. btnp.Enabled = False
  534. End Sub
  535. Private Sub Button19_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnq.Click
  536. Label1.Text = check("q", "", "", "", "")
  537. btnq.Enabled = False
  538. End Sub
  539. Private Sub Button20_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnr.Click
  540. Label1.Text = check("r", "", "", "", "")
  541. btnr.Enabled = False
  542. End Sub
  543. Private Sub Button21_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btns.Click
  544. Label1.Text = check("s", "", "", "", "")
  545. btns.Enabled = False
  546. End Sub
  547. Private Sub Button22_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnt.Click
  548. Label1.Text = check("t", "", "", "", "")
  549. btnt.Enabled = False
  550. End Sub
  551. Private Sub Button23_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnu.Click
  552. Label1.Text = check("u", "", "", "", "")
  553. btnu.Enabled = False
  554. End Sub
  555. Private Sub Button24_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnv.Click
  556. Label1.Text = check("v", "", "", "", "")
  557. btnv.Enabled = False
  558. End Sub
  559. Private Sub Button25_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnw.Click
  560. Label1.Text = check("w", "", "", "", "")
  561. btnw.Enabled = False
  562. End Sub
  563. Private Sub Button26_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnx.Click
  564. Label1.Text = check("x", "", "", "", "")
  565. btnx.Enabled = False
  566. End Sub
  567. Private Sub Button27_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btny.Click
  568. Label1.Text = check("y", "", "", "", "")
  569. btny.Enabled = False
  570. End Sub
  571. Private Sub Button28_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnz.Click
  572. Label1.Text = check("z", "", "", "", "")
  573. btnz.Enabled = False
  574. End Sub
  575.  
  576. '--------------------------------------------------ABCDEFGHIJKLMNOPQRSTUVQXYZ-------------------------------------------------------------------
  577.  
  578.  
  579. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  580. Me.Close()
  581. End Sub
  582. End Class
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 10
Reputation: weazel is an unknown quantity at this point 
Solved Threads: 0
weazel weazel is offline Offline
Newbie Poster

Re: hangman revised

 
0
  #2
Dec 31st, 2004
well.. here is what i have so far...

so far it displays underscores for the word length, it checks if the letter is in there, and if it is, displays it in the correct spot


now can anybody please help me do the counter, meaning, in a label it displays the number of letters remainig in the word, and should go down each time u get a letter right...

 
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 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
    Friend WithEvents btnstart As System.Windows.Forms.Button
    Friend WithEvents lbloutput As System.Windows.Forms.Label
    Friend WithEvents btnexit As System.Windows.Forms.Button
    Friend WithEvents lblwin As System.Windows.Forms.Label
    Friend WithEvents lblloss As System.Windows.Forms.Label
    Friend WithEvents lblleft As System.Windows.Forms.Label
    Friend WithEvents lblwin1 As System.Windows.Forms.Label
    Friend WithEvents lblleft1 As System.Windows.Forms.Label
    Friend WithEvents lblloss1 As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.btnstart = New System.Windows.Forms.Button()
        Me.lbloutput = New System.Windows.Forms.Label()
        Me.btnexit = 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.lblwin = New System.Windows.Forms.Label()
        Me.lblloss = New System.Windows.Forms.Label()
        Me.lblleft = New System.Windows.Forms.Label()
        Me.lblwin1 = New System.Windows.Forms.Label()
        Me.lblleft1 = New System.Windows.Forms.Label()
        Me.lblloss1 = New System.Windows.Forms.Label()
        Me.SuspendLayout()
        '
        'btnstart
        '
        Me.btnstart.Location = New System.Drawing.Point(8, 200)
        Me.btnstart.Name = "btnstart"
        Me.btnstart.Size = New System.Drawing.Size(80, 24)
        Me.btnstart.TabIndex = 0
        Me.btnstart.Text = "Start"
        '
        'lbloutput
        '
        Me.lbloutput.Location = New System.Drawing.Point(168, 208)
        Me.lbloutput.Name = "lbloutput"
        Me.lbloutput.Size = New System.Drawing.Size(232, 40)
        Me.lbloutput.TabIndex = 1
        '
        'btnexit
        '
        Me.btnexit.Location = New System.Drawing.Point(8, 224)
        Me.btnexit.Name = "btnexit"
        Me.btnexit.Size = New System.Drawing.Size(80, 24)
        Me.btnexit.TabIndex = 2
        Me.btnexit.Text = "Exit"
        '
        'btna
        '
        Me.btna.Enabled = False
        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.Enabled = False
        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.Enabled = False
        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.Enabled = False
        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.Enabled = False
        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.Enabled = False
        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.Enabled = False
        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.Enabled = False
        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.Enabled = False
        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.Enabled = False
        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.Enabled = False
        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.Enabled = False
        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.Enabled = False
        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.Enabled = False
        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.Enabled = False
        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.Enabled = False
        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.Enabled = False
        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.Enabled = False
        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.Enabled = False
        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.Enabled = False
        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.Enabled = False
        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.Enabled = False
        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.Enabled = False
        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.Enabled = False
        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.Enabled = False
        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.Enabled = False
        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"
        '
        'lblwin
        '
        Me.lblwin.Font = New System.Drawing.Font("Microsoft Sans Serif", 26.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblwin.Location = New System.Drawing.Point(0, 48)
        Me.lblwin.Name = "lblwin"
        Me.lblwin.Size = New System.Drawing.Size(144, 40)
        Me.lblwin.TabIndex = 30
        Me.lblwin.Text = "Win:"
        '
        'lblloss
        '
        Me.lblloss.Font = New System.Drawing.Font("Microsoft Sans Serif", 26.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblloss.Location = New System.Drawing.Point(0, 88)
        Me.lblloss.Name = "lblloss"
        Me.lblloss.Size = New System.Drawing.Size(144, 40)
        Me.lblloss.TabIndex = 31
        Me.lblloss.Text = "Loss:"
        '
        'lblleft
        '
        Me.lblleft.Font = New System.Drawing.Font("Microsoft Sans Serif", 26.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblleft.Location = New System.Drawing.Point(0, 128)
        Me.lblleft.Name = "lblleft"
        Me.lblleft.Size = New System.Drawing.Size(144, 40)
        Me.lblleft.TabIndex = 32
        Me.lblleft.Text = "Left:"
        '
        'lblwin1
        '
        Me.lblwin1.Location = New System.Drawing.Point(152, 48)
        Me.lblwin1.Name = "lblwin1"
        Me.lblwin1.Size = New System.Drawing.Size(64, 40)
        Me.lblwin1.TabIndex = 33
        '
        'lblleft1
        '
        Me.lblleft1.Location = New System.Drawing.Point(152, 128)
        Me.lblleft1.Name = "lblleft1"
        Me.lblleft1.Size = New System.Drawing.Size(64, 40)
        Me.lblleft1.TabIndex = 34
        '
        'lblloss1
        '
        Me.lblloss1.Location = New System.Drawing.Point(152, 88)
        Me.lblloss1.Name = "lblloss1"
        Me.lblloss1.Size = New System.Drawing.Size(64, 40)
        Me.lblloss1.TabIndex = 35
        '
        '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.lblloss1, Me.lblleft1, Me.lblwin1, Me.lblleft, Me.lblloss, Me.lblwin, 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.btnexit, Me.lbloutput, Me.btnstart})
        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 btnstart.Click

        word = GetNewWord("mm.txt")
        word = word.ToUpper
        enable()
        lbloutput.Text = underscore(word.Length, "")
        lblleft1.Text = 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 = lbloutput.Text
            one = word1.Substring(place * 2 + 1)
            total = letter + one
            Return total
        End If


        If place > 0 Then
            word1 = lbloutput.Text
            two = word1.Substring(0, place * 2)
            one = word1.Substring(place * 2 + 1)
            total = two + letter + one
            Return total
        End If

        If place < 0 Then
            MessageBox.Show("hi")
            Return lbloutput.Text
        End If

        'THIS IS THE COUNTER THAT I NEED HELP WITH
        'If place >= 0 Then
        '    lblleft1.Text = word.Length & counter
        '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
        lbloutput.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
        lbloutput.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
        lbloutput.Text = check("C", "", "", "", "")
    End Sub
    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnd.Click
        btnd.Enabled = False
        lbloutput.Text = check("D", "", "", "", "")
    End Sub
    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btne.Click
        lbloutput.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
        lbloutput.Text = check("F", "", "", "", "")
        btnf.Enabled = False
    End Sub
    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btng.Click
        lbloutput.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
        lbloutput.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
        lbloutput.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
        lbloutput.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
        lbloutput.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
        lbloutput.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
        lbloutput.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
        lbloutput.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
        lbloutput.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
        lbloutput.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
        lbloutput.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
        lbloutput.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
        lbloutput.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
        lbloutput.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
        lbloutput.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
        lbloutput.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
        lbloutput.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
        lbloutput.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
        lbloutput.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
        lbloutput.Text = check("Z", "", "", "", "")
        btnz.Enabled = False
    End Sub

    '--------------------------------------------------ABCDEFGHIJKLMNOPQRSTUVQXYZ-------------------------------------------------------------------


    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnexit.Click
        Me.Close()
    End Sub
End Class
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 445
Reputation: 1o0oBhP is an unknown quantity at this point 
Solved Threads: 6
1o0oBhP's Avatar
1o0oBhP 1o0oBhP is offline Offline
Posting Pro in Training

Re: hangman revised

 
0
  #3
Jan 1st, 2005
Ive programmed in VB for a LONG time but the vb.net code I see is a bit more complex, even some c/c++ inspiration in it! However i had a look at what you are trying to do. When you say the number of letters in the word do you mean individual letters or multiple letters for example

the word is "missed" and the user has got mi___d

would you like to print 2 (e and s missing)
or would you like to get 3 (e and two esses missing)

I assumed you are after recognising the individual letters (the first option). I would still use a boolean array for each letter (26). When you get the word from the file you need to have a temp array of 26 booleans, then go through each letter in the word, setting the appropriate index in the temp array to true (therefore multiple letters wont get counted twice as they have the same index), then going through the ARRAY and counting the number of 'true' states. This gives you the number of different letters in the word. When the user makes a correct guess, decrement this number.

Example:

the word is excited

our array is full of boolean falses (dim letters(25) as boolean or whatever)
we go through the word and get e, so we set letters(4) to true
we go through the word and get x, so we set letters(23) to true
we go through the word and get c, so we set letters(2) to true
we go through the word and get i, so we set letters(8) to true
we go through the word and get t, so we set letters(19) to true
we go through the word and get e, so we set letters(4) to true 'the duplicate e doesnt matter
we go through the word and get d, so we set letters(3) to true

so the array looks a bit like this

a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z
0,0,1,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0

we have 6 true states so there are 6 different letters in the word 'excited', when we get a correct guess we take one from this number so after the user has got:

ex__te_ we have 3 letters left (c, d, and i)
http://sales.carina-e.com

no www
no nonsense

coming soon to a pc near you! :cool:
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 10
Reputation: weazel is an unknown quantity at this point 
Solved Threads: 0
weazel weazel is offline Offline
Newbie Poster

Re: hangman revised

 
0
  #4
Jan 1st, 2005
Originally Posted by 1o0oBhP
Ive programmed in VB for a LONG time but the vb.net code I see is a bit more complex, even some c/c++ inspiration in it! However i had a look at what you are trying to do. When you say the number of letters in the word do you mean individual letters or multiple letters for example

the word is "missed" and the user has got mi___d

would you like to print 2 (e and s missing)
or would you like to get 3 (e and two esses missing)

I assumed you are after recognising the individual letters (the first option). I would still use a boolean array for each letter (26). When you get the word from the file you need to have a temp array of 26 booleans, then go through each letter in the word, setting the appropriate index in the temp array to true (therefore multiple letters wont get counted twice as they have the same index), then going through the ARRAY and counting the number of 'true' states. This gives you the number of different letters in the word. When the user makes a correct guess, decrement this number.

Example:

the word is excited

our array is full of boolean falses (dim letters(25) as boolean or whatever)
we go through the word and get e, so we set letters(4) to true
we go through the word and get x, so we set letters(23) to true
we go through the word and get c, so we set letters(2) to true
we go through the word and get i, so we set letters(8) to true
we go through the word and get t, so we set letters(19) to true
we go through the word and get e, so we set letters(4) to true 'the duplicate e doesnt matter
we go through the word and get d, so we set letters(3) to true

so the array looks a bit like this

a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z
0,0,1,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0

we have 6 true states so there are 6 different letters in the word 'excited', when we get a correct guess we take one from this number so after the user has got:

ex__te_ we have 3 letters left (c, d, and i)


i'm very sorry to say this.. because u actually tried helping me.. but in school we havnt learned about arrays yet.. i bet if we had this would have helped tremendously..

sry for ure trouble, but is there any other way to do this :-D?
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 445
Reputation: 1o0oBhP is an unknown quantity at this point 
Solved Threads: 6
1o0oBhP's Avatar
1o0oBhP 1o0oBhP is offline Offline
Posting Pro in Training

Re: hangman revised

 
0
  #5
Jan 2nd, 2005
not without arrays unless you want to store a LOT of variables!

actually there is one other way i can think of.
Rearrange word alphabetically.
we start be having the number of letters = 1
Instead of the array, store the current string letter and the next
if the next is not the same as the current (ie not a repeated character) increment the number of letters ie

word = test
word goes to estt (alphabetical)
we have one letter

current letter = e
next letter = s
not the same so we have 2 letters (add)
current letter = s
next letter = t
not the same so we have 3 letters (add)
current letter = t
next letter = t
skip

Result = 3 letters in "test" (e, s and t)

A little bit about arrays
----------------------

instead of storing large numbers of variables you can group together some variables in a list called an array (its easier to show you than explain). Each array is of a certain type (array of strings, array of integers ect...) and has a name to identify it

example

Dim test(4) as integer ' this is an array (list) of 5 integers

The number in the brackets is the size of your array (list). In the above example i wanted a list of 5 integers called "test" -> however we have to put a 4 in the brackets!!! (see below)

An array is a list in memory, so each item in the list will be obviously the same 'distance' from one another in memory addresses because they are the same type!

ie

test item 1: mem address x
test item 2: mem address x + (the space of an integer)
test item 3: ...
test item 4: ...
test item 5: ...

so when you specify an index (number in the brackets) you MUST remember that the first element (item) is at address + 0! so the numbering starts from 0, clever that!

Dim prices(9) as currency ' a list of 10 prices as currency variables

prices(0) = 33.28 ' put 33.28 into the first item
prices(5) = 15.00 ' put 15.00 into the 6th item

Dim x as currency

x = prices(4) ' get the data from the 5th item and put it in x (make sure the types match!)

A google search will find someone who can explain arrays MUCH better that I can! arrays also go hand in hand with loops so that may be another area to look up if you do not know loops either!
http://sales.carina-e.com

no www
no nonsense

coming soon to a pc near you! :cool:
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 10
Reputation: weazel is an unknown quantity at this point 
Solved Threads: 0
weazel weazel is offline Offline
Newbie Poster

Re: hangman revised

 
0
  #6
Jan 4th, 2005
Big Problem!!!
ok hangman all worked perfectly... then suddenly this erro came up!!!

SOMEBODY HELP ME PLEASE THIS IS DUE 2MORROW!!!

ERROR = An unhandled exception of type 'System.Runtime.InteropServices.ExternalException' occurred in system.windows.forms.dll

Additional information: A generic error occurred in GDI+.


  1.  
  2. Public Class form1
  3. Inherits System.Windows.Forms.Form
  4. ' Author: Misha Mitsnefes
  5.  
  6. 'Completed On: 1/4/05
  7.  
  8. 'Program Name: Hang the Coyote
  9.  
  10. 'Folder Names: Hang the Coyote
  11.  
  12. 'Description: This is the original hangman game with a little twist, instead of hanging a stick figure, you slowly flip the switch of the electric chair untill the coyote is fried:).
  13.  
  14. ' E V A L U A T I O N
  15.  
  16. ' Pseudocode ____ (10) User Friendly ____ (10)
  17.  
  18. ' Proper Indentation ____ ( 5) Program Structure ____ (10)
  19.  
  20. 'Descriptive Variable Names ____ ( 5) Functionality ____ (50)
  21.  
  22. ' Documentation ____ (10) Bonus/(Penalty) ____ ( ?)
  23.  
  24. ' Total ____ (100)
  25.  
  26. #Region " Windows Form Designer generated code "
  27.  
  28. Public Sub New()
  29. MyBase.New()
  30.  
  31. 'This call is required by the Windows Form Designer.
  32. InitializeComponent()
  33.  
  34. 'Add any initialization after the InitializeComponent() call
  35.  
  36. End Sub
  37.  
  38. 'Form overrides dispose to clean up the component list.
  39. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
  40. If disposing Then
  41. If Not (components Is Nothing) Then
  42. components.Dispose()
  43. End If
  44. End If
  45. MyBase.Dispose(disposing)
  46. End Sub
  47.  
  48. 'Required by the Windows Form Designer
  49. Private components As System.ComponentModel.IContainer
  50.  
  51. 'NOTE: The following procedure is required by the Windows Form Designer
  52. 'It can be modified using the Windows Form Designer.
  53. 'Do not modify it using the code editor.
  54. Friend WithEvents btna As System.Windows.Forms.Button
  55. Friend WithEvents btnm As System.Windows.Forms.Button
  56. Friend WithEvents btnl As System.Windows.Forms.Button
  57. Friend WithEvents btnk As System.Windows.Forms.Button
  58. Friend WithEvents btnj As System.Windows.Forms.Button
  59. Friend WithEvents btni As System.Windows.Forms.Button
  60. Friend WithEvents btng As System.Windows.Forms.Button
  61. Friend WithEvents btnf As System.Windows.Forms.Button
  62. Friend WithEvents btne As System.Windows.Forms.Button
  63. Friend WithEvents btnd As System.Windows.Forms.Button
  64. Friend WithEvents btnc As System.Windows.Forms.Button
  65. Friend WithEvents btnb As System.Windows.Forms.Button
  66. Friend WithEvents btnu As System.Windows.Forms.Button
  67. Friend WithEvents btnt As System.Windows.Forms.Button
  68. Friend WithEvents btns As System.Windows.Forms.Button
  69. Friend WithEvents btnr As System.Windows.Forms.Button
  70. Friend WithEvents btnq As System.Windows.Forms.Button
  71. Friend WithEvents btnp As System.Windows.Forms.Button
  72. Friend WithEvents btno As System.Windows.Forms.Button
  73. Friend WithEvents btnn As System.Windows.Forms.Button
  74. Friend WithEvents btny As System.Windows.Forms.Button
  75. Friend WithEvents btnx As System.Windows.Forms.Button
  76. Friend WithEvents btnw As System.Windows.Forms.Button
  77. Friend WithEvents btnv As System.Windows.Forms.Button
  78. Friend WithEvents btnz As System.Windows.Forms.Button
  79. Friend WithEvents btnh As System.Windows.Forms.Button
  80. Friend WithEvents btnstart As System.Windows.Forms.Button
  81. Friend WithEvents lbloutput As System.Windows.Forms.Label
  82. Friend WithEvents btnexit As System.Windows.Forms.Button
  83. Friend WithEvents lblwin As System.Windows.Forms.Label
  84. Friend WithEvents lblloss As System.Windows.Forms.Label
  85. Friend WithEvents lblwin1 As System.Windows.Forms.Label
  86. Friend WithEvents lblloss1 As System.Windows.Forms.Label
  87. Friend WithEvents lblguesses1 As System.Windows.Forms.Label
  88. Friend WithEvents lblguesses As System.Windows.Forms.Label
  89. Friend WithEvents lblmisses1 As System.Windows.Forms.Label
  90. Friend WithEvents lblmisses As System.Windows.Forms.Label
  91. Friend WithEvents lbllefty As System.Windows.Forms.Label
  92. Friend WithEvents lbllefty1 As System.Windows.Forms.Label
  93. Friend WithEvents picturebox As System.Windows.Forms.PictureBox
  94. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
  95. Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(form1))
  96. Me.btnstart = New System.Windows.Forms.Button()
  97. Me.lbloutput = New System.Windows.Forms.Label()
  98. Me.btnexit = New System.Windows.Forms.Button()
  99. Me.btna = New System.Windows.Forms.Button()
  100. Me.btnm = New System.Windows.Forms.Button()
  101. Me.btnl = New System.Windows.Forms.Button()
  102. Me.btnk = New System.Windows.Forms.Button()
  103. Me.btnj = New System.Windows.Forms.Button()
  104. Me.btni = New System.Windows.Forms.Button()
  105. Me.btnh = New System.Windows.Forms.Button()
  106. Me.btng = New System.Windows.Forms.Button()
  107. Me.btnf = New System.Windows.Forms.Button()
  108. Me.btne = New System.Windows.Forms.Button()
  109. Me.btnd = New System.Windows.Forms.Button()
  110. Me.btnc = New System.Windows.Forms.Button()
  111. Me.btnb = New System.Windows.Forms.Button()
  112. Me.btny = New System.Windows.Forms.Button()
  113. Me.btnx = New System.Windows.Forms.Button()
  114. Me.btnw = New System.Windows.Forms.Button()
  115. Me.btnv = New System.Windows.Forms.Button()
  116. Me.btnu = New System.Windows.Forms.Button()
  117. Me.btnt = New System.Windows.Forms.Button()
  118. Me.btns = New System.Windows.Forms.Button()
  119. Me.btnr = New System.Windows.Forms.Button()
  120. Me.btnq = New System.Windows.Forms.Button()
  121. Me.btnp = New System.Windows.Forms.Button()
  122. Me.btno = New System.Windows.Forms.Button()
  123. Me.btnn = New System.Windows.Forms.Button()
  124. Me.btnz = New System.Windows.Forms.Button()
  125. Me.lblwin = New System.Windows.Forms.Label()
  126. Me.lblloss = New System.Windows.Forms.Label()
  127. Me.lbllefty = New System.Windows.Forms.Label()
  128. Me.lblwin1 = New System.Windows.Forms.Label()
  129. Me.lbllefty1 = New System.Windows.Forms.Label()
  130. Me.lblloss1 = New System.Windows.Forms.Label()
  131. Me.lblguesses1 = New System.Windows.Forms.Label()
  132. Me.lblguesses = New System.Windows.Forms.Label()
  133. Me.lblmisses1 = New System.Windows.Forms.Label()
  134. Me.lblmisses = New System.Windows.Forms.Label()
  135. Me.picturebox = New System.Windows.Forms.PictureBox()
  136. Me.SuspendLayout()
  137. '
  138. 'btnstart
  139. '
  140. Me.btnstart.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  141. Me.btnstart.ForeColor = System.Drawing.Color.Firebrick
  142. Me.btnstart.Location = New System.Drawing.Point(48, 328)
  143. Me.btnstart.Name = "btnstart"
  144. Me.btnstart.Size = New System.Drawing.Size(80, 24)
  145. Me.btnstart.TabIndex = 0
  146. Me.btnstart.Text = "Start"
  147. '
  148. 'lbloutput
  149. '
  150. Me.lbloutput.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  151. Me.lbloutput.ForeColor = System.Drawing.Color.Firebrick
  152. Me.lbloutput.Location = New System.Drawing.Point(200, 328)
  153. Me.lbloutput.Name = "lbloutput"
  154. Me.lbloutput.Size = New System.Drawing.Size(408, 40)
  155. Me.lbloutput.TabIndex = 1
  156. Me.lbloutput.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
  157. '
  158. 'btnexit
  159. '
  160. Me.btnexit.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  161. Me.btnexit.ForeColor = System.Drawing.Color.Firebrick
  162. Me.btnexit.Location = New System.Drawing.Point(672, 328)
  163. Me.btnexit.Name = "btnexit"
  164. Me.btnexit.Size = New System.Drawing.Size(80, 24)
  165. Me.btnexit.TabIndex = 2
  166. Me.btnexit.Text = "Exit"
  167. '
  168. 'btna
  169. '
  170. Me.btna.Enabled = False
  171. Me.btna.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  172. Me.btna.ForeColor = System.Drawing.Color.Firebrick
  173. Me.btna.Location = New System.Drawing.Point(192, 384)
  174. Me.btna.Name = "btna"
  175. Me.btna.Size = New System.Drawing.Size(32, 32)
  176. Me.btna.TabIndex = 3
  177. Me.btna.Text = "A"
  178. '
  179. 'btnm
  180. '
  181. Me.btnm.Enabled = False
  182. Me.btnm.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  183. Me.btnm.ForeColor = System.Drawing.Color.Firebrick
  184. Me.btnm.Location = New System.Drawing.Point(576, 384)
  185. Me.btnm.Name = "btnm"
  186. Me.btnm.Size = New System.Drawing.Size(32, 32)
  187. Me.btnm.TabIndex = 4
  188. Me.btnm.Text = "M"
  189. '
  190. 'btnl
  191. '
  192. Me.btnl.Enabled = False
  193. Me.btnl.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  194. Me.btnl.ForeColor = System.Drawing.Color.Firebrick
  195. Me.btnl.Location = New System.Drawing.Point(544, 384)
  196. Me.btnl.Name = "btnl"
  197. Me.btnl.Size = New System.Drawing.Size(32, 32)
  198. Me.btnl.TabIndex = 5
  199. Me.btnl.Text = "L"
  200. '
  201. 'btnk
  202. '
  203. Me.btnk.Enabled = False
  204. Me.btnk.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  205. Me.btnk.ForeColor = System.Drawing.Color.Firebrick
  206. Me.btnk.Location = New System.Drawing.Point(512, 384)
  207. Me.btnk.Name = "btnk"
  208. Me.btnk.Size = New System.Drawing.Size(32, 32)
  209. Me.btnk.TabIndex = 6
  210. Me.btnk.Text = "K"
  211. '
  212. 'btnj
  213. '
  214. Me.btnj.Enabled = False
  215. Me.btnj.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  216. Me.btnj.ForeColor = System.Drawing.Color.Firebrick
  217. Me.btnj.Location = New System.Drawing.Point(480, 384)
  218. Me.btnj.Name = "btnj"
  219. Me.btnj.Size = New System.Drawing.Size(32, 32)
  220. Me.btnj.TabIndex = 7
  221. Me.btnj.Text = "J"
  222. '
  223. 'btni
  224. '
  225. Me.btni.Enabled = False
  226. Me.btni.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  227. Me.btni.ForeColor = System.Drawing.Color.Firebrick
  228. Me.btni.Location = New System.Drawing.Point(448, 384)
  229. Me.btni.Name = "btni"
  230. Me.btni.Size = New System.Drawing.Size(32, 32)
  231. Me.btni.TabIndex = 8
  232. Me.btni.Text = "I"
  233. '
  234. 'btnh
  235. '
  236. Me.btnh.Enabled = False
  237. Me.btnh.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  238. Me.btnh.ForeColor = System.Drawing.Color.Firebrick
  239. Me.btnh.Location = New System.Drawing.Point(416, 384)
  240. Me.btnh.Name = "btnh"
  241. Me.btnh.Size = New System.Drawing.Size(32, 32)
  242. Me.btnh.TabIndex = 9
  243. Me.btnh.Text = "H"
  244. '
  245. 'btng
  246. '
  247. Me.btng.Enabled = False
  248. Me.btng.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  249. Me.btng.ForeColor = System.Drawing.Color.Firebrick
  250. Me.btng.Location = New System.Drawing.Point(384, 384)
  251. Me.btng.Name = "btng"
  252. Me.btng.Size = New System.Drawing.Size(32, 32)
  253. Me.btng.TabIndex = 10
  254. Me.btng.Text = "G"
  255. '
  256. 'btnf
  257. '
  258. Me.btnf.Enabled = False
  259. Me.btnf.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  260. Me.btnf.ForeColor = System.Drawing.Color.Firebrick
  261. Me.btnf.Location = New System.Drawing.Point(352, 384)
  262. Me.btnf.Name = "btnf"
  263. Me.btnf.Size = New System.Drawing.Size(32, 32)
  264. Me.btnf.TabIndex = 11
  265. Me.btnf.Text = "F"
  266. '
  267. 'btne
  268. '
  269. Me.btne.Enabled = False
  270. Me.btne.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  271. Me.btne.ForeColor = System.Drawing.Color.Firebrick
  272. Me.btne.Location = New System.Drawing.Point(320, 384)
  273. Me.btne.Name = "btne"
  274. Me.btne.Size = New System.Drawing.Size(32, 32)
  275. Me.btne.TabIndex = 12
  276. Me.btne.Text = "E"
  277. '
  278. 'btnd
  279. '
  280. Me.btnd.Enabled = False
  281. Me.btnd.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  282. Me.btnd.ForeColor = System.Drawing.Color.Firebrick
  283. Me.btnd.Location = New System.Drawing.Point(288, 384)
  284. Me.btnd.Name = "btnd"
  285. Me.btnd.Size = New System.Drawing.Size(32, 32)
  286. Me.btnd.TabIndex = 13
  287. Me.btnd.Text = "D"
  288. '
  289. 'btnc
  290. '
  291. Me.btnc.Enabled = False
  292. Me.btnc.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  293. Me.btnc.ForeColor = System.Drawing.Color.Firebrick
  294. Me.btnc.Location = New System.Drawing.Point(256, 384)
  295. Me.btnc.Name = "btnc"
  296. Me.btnc.Size = New System.Drawing.Size(32, 32)
  297. Me.btnc.TabIndex = 14
  298. Me.btnc.Text = "C"
  299. '
  300. 'btnb
  301. '
  302. Me.btnb.Enabled = False
  303. Me.btnb.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  304. Me.btnb.ForeColor = System.Drawing.Color.Firebrick
  305. Me.btnb.Location = New System.Drawing.Point(224, 384)
  306. Me.btnb.Name = "btnb"
  307. Me.btnb.Size = New System.Drawing.Size(32, 32)
  308. Me.btnb.TabIndex = 15
  309. Me.btnb.Text = "B"
  310. '
  311. 'btny
  312. '
  313. Me.btny.Enabled = False
  314. Me.btny.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  315. Me.btny.ForeColor = System.Drawing.Color.Firebrick
  316. Me.btny.Location = New System.Drawing.Point(544, 416)
  317. Me.btny.Name = "btny"
  318. Me.btny.Size = New System.Drawing.Size(32, 32)
  319. Me.btny.TabIndex = 16
  320. Me.btny.Text = "Y"
  321. '
  322. 'btnx
  323. '
  324. Me.btnx.Enabled = False
  325. Me.btnx.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  326. Me.btnx.ForeColor = System.Drawing.Color.Firebrick
  327. Me.btnx.Location = New System.Drawing.Point(512, 416)
  328. Me.btnx.Name = "btnx"
  329. Me.btnx.Size = New System.Drawing.Size(32, 32)
  330. Me.btnx.TabIndex = 17
  331. Me.btnx.Text = "X"
  332. '
  333. 'btnw
  334. '
  335. Me.btnw.Enabled = False
  336. Me.btnw.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  337. Me.btnw.ForeColor = System.Drawing.Color.Firebrick
  338. Me.btnw.Location = New System.Drawing.Point(480, 416)
  339. Me.btnw.Name = "btnw"
  340. Me.btnw.Size = New System.Drawing.Size(32, 32)
  341. Me.btnw.TabIndex = 18
  342. Me.btnw.Text = "W"
  343. '
  344. 'btnv
  345. '
  346. Me.btnv.Enabled = False
  347. Me.btnv.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  348. Me.btnv.ForeColor = System.Drawing.Color.Firebrick
  349. Me.btnv.Location = New System.Drawing.Point(448, 416)
  350. Me.btnv.Name = "btnv"
  351. Me.btnv.Size = New System.Drawing.Size(32, 32)
  352. Me.btnv.TabIndex = 19
  353. Me.btnv.Text = "V"
  354. '
  355. 'btnu
  356. '
  357. Me.btnu.Enabled = False
  358. Me.btnu.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  359. Me.btnu.ForeColor = System.Drawing.Color.Firebrick
  360. Me.btnu.Location = New System.Drawing.Point(416, 416)
  361. Me.btnu.Name = "btnu"
  362. Me.btnu.Size = New System.Drawing.Size(32, 32)
  363. Me.btnu.TabIndex = 20
  364. Me.btnu.Text = "U"
  365. '
  366. 'btnt
  367. '
  368. Me.btnt.Enabled = False
  369. Me.btnt.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  370. Me.btnt.ForeColor = System.Drawing.Color.Firebrick
  371. Me.btnt.Location = New System.Drawing.Point(384, 416)
  372. Me.btnt.Name = "btnt"
  373. Me.btnt.Size = New System.Drawing.Size(32, 32)
  374. Me.btnt.TabIndex = 21
  375. Me.btnt.Text = "T"
  376. '
  377. 'btns
  378. '
  379. Me.btns.Enabled = False
  380. Me.btns.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  381. Me.btns.ForeColor = System.Drawing.Color.Firebrick
  382. Me.btns.Location = New System.Drawing.Point(352, 416)
  383. Me.btns.Name = "btns"
  384. Me.btns.Size = New System.Drawing.Size(32, 32)
  385. Me.btns.TabIndex = 22
  386. Me.btns.Text = "S"
  387. '
  388. 'btnr
  389. '
  390. Me.btnr.Enabled = False
  391. Me.btnr.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  392. Me.btnr.ForeColor = System.Drawing.Color.Firebrick
  393. Me.btnr.Location = New System.Drawing.Point(320, 416)
  394. Me.btnr.Name = "btnr"
  395. Me.btnr.Size = New System.Drawing.Size(32, 32)
  396. Me.btnr.TabIndex = 23
  397. Me.btnr.Text = "R"
  398. '
  399. 'btnq
  400. '
  401. Me.btnq.Enabled = False
  402. Me.btnq.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  403. Me.btnq.ForeColor = System.Drawing.Color.Firebrick
  404. Me.btnq.Location = New System.Drawing.Point(288, 416)
  405. Me.btnq.Name = "btnq"
  406. Me.btnq.Size = New System.Drawing.Size(32, 32)
  407. Me.btnq.TabIndex = 24
  408. Me.btnq.Text = "Q"
  409. '
  410. 'btnp
  411. '
  412. Me.btnp.Enabled = False
  413. Me.btnp.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  414. Me.btnp.ForeColor = System.Drawing.Color.Firebrick
  415. Me.btnp.Location = New System.Drawing.Point(256, 416)
  416. Me.btnp.Name = "btnp"
  417. Me.btnp.Size = New System.Drawing.Size(32, 32)
  418. Me.btnp.TabIndex = 25
  419. Me.btnp.Text = "P"
  420. '
  421. 'btno
  422. '
  423. Me.btno.Enabled = False
  424. Me.btno.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  425. Me.btno.ForeColor = System.Drawing.Color.Firebrick
  426. Me.btno.Location = New System.Drawing.Point(224, 416)
  427. Me.btno.Name = "btno"
  428. Me.btno.Size = New System.Drawing.Size(32, 32)
  429. Me.btno.TabIndex = 26
  430. Me.btno.Text = "O"
  431. '
  432. 'btnn
  433. '
  434. Me.btnn.Enabled = False
  435. Me.btnn.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  436. Me.btnn.ForeColor = System.Drawing.Color.Firebrick
  437. Me.btnn.Location = New System.Drawing.Point(192, 416)
  438. Me.btnn.Name = "btnn"
  439. Me.btnn.Size = New System.Drawing.Size(32, 32)
  440. Me.btnn.TabIndex = 27
  441. Me.btnn.Text = "N"
  442. '
  443. 'btnz
  444. '
  445. Me.btnz.Enabled = False
  446. Me.btnz.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  447. Me.btnz.ForeColor = System.Drawing.Color.Firebrick
  448. Me.btnz.Location = New System.Drawing.Point(576, 416)
  449. Me.btnz.Name = "btnz"
  450. Me.btnz.Size = New System.Drawing.Size(32, 32)
  451. Me.btnz.TabIndex = 29
  452. Me.btnz.Text = "Z"
  453. '
  454. 'lblwin
  455. '
  456. Me.lblwin.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  457. Me.lblwin.ForeColor = System.Drawing.Color.Firebrick
  458. Me.lblwin.Location = New System.Drawing.Point(192, 464)
  459. Me.lblwin.Name = "lblwin"
  460. Me.lblwin.Size = New System.Drawing.Size(144, 40)
  461. Me.lblwin.TabIndex = 30
  462. Me.lblwin.Text = "Win:"
  463. '
  464. 'lblloss
  465. '
  466. Me.lblloss.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  467. Me.lblloss.ForeColor = System.Drawing.Color.Firebrick
  468. Me.lblloss.Location = New System.Drawing.Point(408, 464)
  469. Me.lblloss.Name = "lblloss"
  470. Me.lblloss.Size = New System.Drawing.Size(144, 40)
  471. Me.lblloss.TabIndex = 31
  472. Me.lblloss.Text = "Loss:"
  473. '
  474. 'lbllefty
  475. '
  476. Me.lbllefty.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  477. Me.lbllefty.ForeColor = System.Drawing.Color.Firebrick
  478. Me.lbllefty.Location = New System.Drawing.Point(288, 8)
  479. Me.lbllefty.Name = "lbllefty"
  480. Me.lbllefty.Size = New System.Drawing.Size(144, 40)
  481. Me.lbllefty.TabIndex = 32
  482. Me.lbllefty.Text = "Left:"
  483. '
  484. 'lblwin1
  485. '
  486. Me.lblwin1.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  487. Me.lblwin1.ForeColor = System.Drawing.Color.Firebrick
  488. Me.lblwin1.Location = New System.Drawing.Point(328, 464)
  489. Me.lblwin1.Name = "lblwin1"
  490. Me.lblwin1.Size = New System.Drawing.Size(64, 40)
  491. Me.lblwin1.TabIndex = 33
  492. '
  493. 'lbllefty1
  494. '
  495. Me.lbllefty1.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  496. Me.lbllefty1.ForeColor = System.Drawing.Color.Firebrick
  497. Me.lbllefty1.Location = New System.Drawing.Point(432, 8)
  498. Me.lbllefty1.Name = "lbllefty1"
  499. Me.lbllefty1.Size = New System.Drawing.Size(64, 40)
  500. Me.lbllefty1.TabIndex = 34
  501. '
  502. 'lblloss1
  503. '
  504. Me.lblloss1.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  505. Me.lblloss1.ForeColor = System.Drawing.Color.Firebrick
  506. Me.lblloss1.Location = New System.Drawing.Point(544, 464)
  507. Me.lblloss1.Name = "lblloss1"
  508. Me.lblloss1.Size = New System.Drawing.Size(64, 40)
  509. Me.lblloss1.TabIndex = 35
  510. '
  511. 'lblguesses1
  512. '
  513. Me.lblguesses1.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  514. Me.lblguesses1.ForeColor = System.Drawing.Color.Firebrick
  515. Me.lblguesses1.Location = New System.Drawing.Point(152, 8)
  516. Me.lblguesses1.Name = "lblguesses1"
  517. Me.lblguesses1.Size = New System.Drawing.Size(64, 40)
  518. Me.lblguesses1.TabIndex = 37
  519. '
  520. 'lblguesses
  521. '
  522. Me.lblguesses.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  523. Me.lblguesses.ForeColor = System.Drawing.Color.Firebrick
  524. Me.lblguesses.Location = New System.Drawing.Point(8, 8)
  525. Me.lblguesses.Name = "lblguesses"
  526. Me.lblguesses.Size = New System.Drawing.Size(144, 40)
  527. Me.lblguesses.TabIndex = 36
  528. Me.lblguesses.Text = "Guesses:"
  529. '
  530. 'lblmisses1
  531. '
  532. Me.lblmisses1.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  533. Me.lblmisses1.ForeColor = System.Drawing.Color.Firebrick
  534. Me.lblmisses1.Location = New System.Drawing.Point(712, 8)
  535. Me.lblmisses1.Name = "lblmisses1"
  536. Me.lblmisses1.Size = New System.Drawing.Size(64, 40)
  537. Me.lblmisses1.TabIndex = 39
  538. '
  539. 'lblmisses
  540. '
  541. Me.lblmisses.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  542. Me.lblmisses.ForeColor = System.Drawing.Color.Firebrick
  543. Me.lblmisses.Location = New System.Drawing.Point(568, 8)
  544. Me.lblmisses.Name = "lblmisses"
  545. Me.lblmisses.Size = New System.Drawing.Size(144, 40)
  546. Me.lblmisses.TabIndex = 38
  547. Me.lblmisses.Text = "Misses:"
  548. '
  549. 'picturebox
  550. '
  551. Me.picturebox.Image = CType(resources.GetObject("picturebox.Image"), System.Drawing.Bitmap)
  552. Me.picturebox.Location = New System.Drawing.Point(216, 56)
  553. Me.picturebox.Name = "picturebox"
  554. Me.picturebox.Size = New System.Drawing.Size(336, 264)
  555. Me.picturebox.TabIndex = 40
  556. Me.picturebox.TabStop = False
  557. '
  558. 'form1
  559. '
  560. Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
  561. Me.BackColor = System.Drawing.Color.Black
  562. Me.ClientSize = New System.Drawing.Size(784, 518)
  563. Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.picturebox, Me.lblmisses1, Me.lblmisses, Me.lblguesses1, Me.lblguesses, Me.lblloss1, Me.lbllefty1, Me.lblwin1, Me.lbllefty, Me.lblloss, Me.lblwin, 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.btnexit, Me.lbloutput, Me.btnstart})
  564. Me.Name = "form1"
  565. Me.Text = "Hangman Game"
  566. Me.ResumeLayout(False)
  567.  
  568. End Sub
  569.  
  570. #End Region
  571.  
  572. Dim word As String
  573. Dim counter As Integer
  574. Dim length As Decimal
  575. Dim display As String
  576.  
  577.  
  578.  
  579.  
  580. 'play button
  581. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnstart.Click
  582. word = GetNewWord("mm.txt") 'gets word from txt file
  583. enable() 'when play is clicked all letters are enabled
  584. lbloutput.Text = underscore(word.Length, "") 'displays underscores
  585. lblmisses1.Text = "0" 'resets
  586. lbllefty1.Text = "5" 'resets
  587. lblguesses1.Text = "0" 'resets
  588. If lbloutput.Text = "" Then 'message when u run out of words
  589. MessageBox.Show("Sorry... you dont get to kill Wile E. Coyote again. You ran out of words...")
  590. End If
  591. picturebox.Image = Image.FromFile("1.jpg") 'resets first image
  592. End Sub
  593.  
  594.  
  595. 'underscore function
  596. Private Function underscore(ByVal wordlength As Integer, ByVal undscore As String) As String
  597. For wordlength = 0 To wordlength - 1
  598. undscore += "_ "
  599. Next
  600.  
  601. Return undscore
  602. End Function
  603.  
  604. 'main function
  605. Private Function check(ByVal letter As String, ByVal place As Integer, ByVal testletter As String) As String
  606. Dim word1 As String
  607. Dim total As String
  608. Dim one As String
  609. Dim two As String
  610. If letter.ToUpper = testletter.ToUpper Then
  611. If place = 0 Then
  612. word1 = lbloutput.Text
  613. one = word1.Substring(place * 2 + 1)
  614. total = letter + one
  615. Return total
  616. End If
  617. If place > 0 Then
  618. word1 = lbloutput.Text
  619. two = word1.Substring(0, place * 2)
  620. one = word1.Substring(place * 2 + 1)
  621. total = two + letter + one
  622. Return total
  623. End If
  624. Else
  625. Return lbloutput.Text
  626. End If
  627. End Function
  628.  
  629.  
  630.  
  631. 'sub that is sent to main function to display word
  632. Private Sub ihatesubs(ByVal letter As String)
  633. Dim intcounter As Integer
  634. For intcounter = 0 To word.Length - 1 Step 1
  635. lbloutput.Text = check(letter, intcounter, word.Substring(intcounter, 1))
  636. Next
  637.  
  638.  
  639. End Sub
  640.  
  641. 'function to determine how many letters left to click
  642. Private Function lefty()
  643. lbllefty1.Text = 5 - Val(lblmisses1.Text)
  644. End Function
  645.  
  646. 'function to count the number of letters clicked
  647. Private Sub guesses()
  648. lblguesses1.Text = Val(lblguesses1.Text) + 1
  649. End Sub
  650.  
  651. 'functino to determine number of wrong letters clicked, also to display images when wrong
  652. Private Sub misses(ByVal letter As String)
  653. If word.IndexOf(letter) = -1 Then
  654. lblmisses1.Text = Val(lblmisses1.Text) + 1
  655. End If
  656. If lblmisses1.Text = "1" Then
  657. picturebox.Image = Image.FromFile("cayote1.gif")
  658. End If
  659. If lblmisses1.Text = "2" Then
  660. picturebox.Image = Image.FromFile("cayote2.gif")
  661. End If
  662. If lblmisses1.Text = "3" Then
  663. picturebox.Image = Image.FromFile("cayote3.gif")
  664. End If
  665. If lblmisses1.Text = "4" Then
  666. picturebox.Image = Image.FromFile("uho.jpg")
  667. End If
  668. If lblmisses1.Text = "5" Then
  669. picturebox.Image = Image.FromFile("6.jpg")
  670. End If
  671. End Sub
  672. Private Sub lose()
  673. If lblmisses1.Text = "5" Then
  674. lblloss1.Text = Val(lblloss1.Text) + 1
  675. lblmisses1.Text = "0"
  676. lbllefty1.Text = "5"
  677. lblguesses1.Text = "0"
  678. disable()
  679. MessageBox.Show("YAY!!!! YOU GOT TO KILL HIM!!!! :) ... The word was " & word)
  680.  
  681. End If
  682. End Sub
  683. Private Sub win()
  684. If lbloutput.Text.IndexOf("_") = -1 Then
  685. lblwin1.Text = Val(lblwin1.Text) + 1
  686. disable()
  687. lblmisses1.Text = "0"
  688. lbllefty1.Text = "5"
  689. lblguesses1.Text = "0"
  690. MessageBox.Show("Awww... you didn't get to kill him, thats ok, you can try again!")
  691. End If
  692. End Sub
  693.  
  694.  
  695.  
  696.  
  697.  
  698. Private Function enable()
  699. btna.Enabled = True
  700. btnb.Enabled = True
  701. btnc.Enabled = True
  702. btnd.Enabled = True
  703. btne.Enabled = True
  704. btnf.Enabled = True
  705. btng.Enabled = True
  706. btnh.Enabled = True
  707. btni.Enabled = True
  708. btnj.Enabled = True
  709. btnk.Enabled = True
  710. btnl.Enabled = True
  711. btnm.Enabled = True
  712. btnn.Enabled = True
  713. btno.Enabled = True
  714. btnp.Enabled = True
  715. btnq.Enabled = True
  716. btnr.Enabled = True
  717. btns.Enabled = True
  718. btnt.Enabled = True
  719. btnu.Enabled = True
  720. btnv.Enabled = True
  721. btnw.Enabled = True
  722. btnx.Enabled = True
  723. btny.Enabled = True
  724. btnz.Enabled = True
  725. End Function
  726.  
  727. Private Function disable()
  728. btna.Enabled = False
  729. btnb.Enabled = False
  730. btnc.Enabled = False
  731. btnd.Enabled = False
  732. btne.Enabled = False
  733. btnf.Enabled = False
  734. btng.Enabled = False
  735. btnh.Enabled = False
  736. btni.Enabled = False
  737. btnj.Enabled = False
  738. btnk.Enabled = False
  739. btnl.Enabled = False
  740. btnm.Enabled = False
  741. btnn.Enabled = False
  742. btno.Enabled = False
  743. btnp.Enabled = False
  744. btnq.Enabled = False
  745. btnr.Enabled = False
  746. btns.Enabled = False
  747. btnt.Enabled = False
  748. btnu.Enabled = False
  749. btnv.Enabled = False
  750. btnw.Enabled = False
  751. btnx.Enabled = False
  752. btny.Enabled = False
  753. btnz.Enabled = False
  754. End Function
  755.  
  756.  
  757.  
  758.  
  759.  
  760.  
  761.  
  762.  
  763.  
  764. '----------------------------------------------------LETTER CLICK EVENTS--------------------------------------------------------------------
  765. Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btna.Click
  766. btna.Enabled = False
  767. ihatesubs("a")
  768. misses("a")
  769. lefty()
  770. guesses()
  771. lose()
  772. win()
  773. End Sub
  774. Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnb.Click
  775. btnb.Enabled = False
  776. ihatesubs("b")
  777. misses("b")
  778. lefty()
  779. guesses()
  780. lose()
  781. win()
  782. End Sub
  783. Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnc.Click
  784. btnc.Enabled = False
  785. ihatesubs("c")
  786. misses("c")
  787. lefty()
  788. guesses()
  789. lose()
  790. win()
  791. End Sub
  792. Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnd.Click
  793. btnd.Enabled = False
  794. ihatesubs("d")
  795. misses("d")
  796. lefty()
  797. guesses()
  798. lose()
  799. win()
  800. End Sub
  801. Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btne.Click
  802. ihatesubs("e")
  803. btne.Enabled = False
  804. misses("e")
  805. win()
  806. lefty()
  807. guesses()
  808. lose()
  809. End Sub
  810. Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnf.Click
  811. ihatesubs("f")
  812. btnf.Enabled = False
  813. misses("f")
  814. win()
  815. lefty()
  816. guesses()
  817. lose()
  818. End Sub
  819. Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btng.Click
  820. ihatesubs("g")
  821. btng.Enabled = False
  822. misses("g")
  823. win()
  824. lefty()
  825. guesses()
  826. lose()
  827. End Sub
  828. Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnh.Click
  829. ihatesubs("h")
  830. btnh.Enabled = False
  831. misses("h")
  832. win()
  833. lefty()
  834. guesses()
  835. lose()
  836. End Sub
  837. Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btni.Click
  838. ihatesubs("i")
  839. btni.Enabled = False
  840. misses("i")
  841. win()
  842. lefty()
  843. guesses()
  844. lose()
  845. End Sub
  846. Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnj.Click
  847. ihatesubs("j")
  848. btnj.Enabled = False
  849. misses("j")
  850. win()
  851. lefty()
  852. guesses()
  853. lose()
  854. End Sub
  855. Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnk.Click
  856. ihatesubs("k")
  857. btnk.Enabled = False
  858. misses("k")
  859. win()
  860. lefty()
  861. guesses()
  862. lose()
  863. End Sub
  864. Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnl.Click
  865. ihatesubs("l")
  866. btnl.Enabled = False
  867. misses("l")
  868. win()
  869. lefty()
  870. guesses()
  871. lose()
  872. End Sub
  873. Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnm.Click
  874. ihatesubs("m")
  875. btnm.Enabled = False
  876. misses("m")
  877. win()
  878. lefty()
  879. guesses()
  880. lose()
  881. End Sub
  882. Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnn.Click
  883. ihatesubs("n")
  884. btnn.Enabled = False
  885. misses("n")
  886. win()
  887. lefty()
  888. guesses()
  889. lose()
  890. End Sub
  891. Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btno.Click
  892. ihatesubs("o")
  893. btno.Enabled = False
  894. misses("o")
  895. win()
  896. lefty()
  897. guesses()
  898. lose()
  899. End Sub
  900. Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnp.Click
  901. ihatesubs("p")
  902. btnp.Enabled = False
  903. misses("p")
  904. win()
  905. lefty()
  906. guesses()
  907. lose()
  908. End Sub
  909. Private Sub Button19_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnq.Click
  910. ihatesubs("q")
  911. btnq.Enabled = False
  912. misses("q")
  913. win()
  914. lefty()
  915. guesses()
  916. lose()
  917. End Sub
  918. Private Sub Button20_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnr.Click
  919. ihatesubs("r")
  920. btnr.Enabled = False
  921. misses("r")
  922. win()
  923. lefty()
  924. guesses()
  925. lose()
  926. End Sub
  927. Private Sub Button21_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btns.Click
  928. ihatesubs("s")
  929. btns.Enabled = False
  930. misses("s")
  931. win()
  932. lefty()
  933. guesses()
  934. lose()
  935. End Sub
  936. Private Sub Button22_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnt.Click
  937. ihatesubs("t")
  938. btnt.Enabled = False
  939. misses("t")
  940. win()
  941. lefty()
  942. guesses()
  943. lose()
  944. End Sub
  945. Private Sub Button23_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnu.Click
  946. ihatesubs("u")
  947. btnu.Enabled = False
  948. misses("u")
  949. win()
  950. lefty()
  951. guesses()
  952. lose()
  953. End Sub
  954. Private Sub Button24_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnv.Click
  955. ihatesubs("v")
  956. btnv.Enabled = False
  957. misses("v")
  958. win()
  959. lefty()
  960. guesses()
  961. lose()
  962. End Sub
  963. Private Sub Button25_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnw.Click
  964. ihatesubs("w")
  965. btnw.Enabled = False
  966. misses("w")
  967. win()
  968. lefty()
  969. guesses()
  970. lose()
  971. End Sub
  972. Private Sub Button26_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnx.Click
  973. ihatesubs("x")
  974. btnx.Enabled = False
  975. misses("x")
  976. win()
  977. lefty()
  978. guesses()
  979. lose()
  980. End Sub
  981. Private Sub Button27_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btny.Click
  982. ihatesubs("y")
  983. btny.Enabled = False
  984. misses("y")
  985. win()
  986. lefty()
  987. guesses()
  988. lose()
  989. End Sub
  990. Private Sub Button28_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnz.Click
  991. ihatesubs("z")
  992. btnz.Enabled = False
  993. misses("z")
  994. win()
  995. lefty()
  996. guesses()
  997. lose()
  998. End Sub
  999.  
  1000. '--------------------------------------------------ABCDEFGHIJKLMNOPQRSTUVQXYZ-------------------------------------------------------------------
  1001.  
  1002.  
  1003. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnexit.Click
  1004. Me.Close()
  1005. End Sub
  1006.  
  1007.  
  1008.  
  1009. Private Sub lblguesses1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblguesses1.Click
  1010.  
  1011. End Sub
  1012. End Class

ok hangman all worked perfectly... then suddenly this erro came up!!!

SOMEBODY HELP ME PLEASE THIS IS DUE 2MORROW!!!
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 1
Reputation: ryan3842 is an unknown quantity at this point 
Solved Threads: 0
ryan3842 ryan3842 is offline Offline
Newbie Poster

Re: hangman revised

 
0
  #7
Jan 6th, 2005
in your function for the misses, its a sub instead of a function. i have no idea if that is causing the problem, just noticed it and decided to point it out. ive got clark to..... and im just now finishing the project and its thursday night haha. good luck.... this program is frustrating
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 445
Reputation: 1o0oBhP is an unknown quantity at this point 
Solved Threads: 6
1o0oBhP's Avatar
1o0oBhP 1o0oBhP is offline Offline
Posting Pro in Training

Re: hangman revised

 
0
  #8
Jan 18th, 2005
this program is frustrating
Hangman in VB????? if you can do the following:

1) Use an array
2) Use strings

it'll be all over in minutes! or maybe thats just me... If you havent been taught arrays (earlier posts) then ill agree it becomes harder but with a pen and paper you should be able design a program to solve it fairly quickly. How did it go anyway as ive been away for a while and havent seen this post in time to help before the deadline
http://sales.carina-e.com

no www
no nonsense

coming soon to a pc near you! :cool:
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3
Reputation: nimu01234 is an unknown quantity at this point 
Solved Threads: 0
nimu01234 nimu01234 is offline Offline
Newbie Poster

Re: hangman revised

 
0
  #9
May 24th, 2006
If U can send me the Hangman Project as a ZIP File den can tel my dad to look at it. cause he is a teacher . i m sure he will be able to help you with


Originally Posted by weazel
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

  1. Public Class Form1
  2. Inherits System.Windows.Forms.Form
  3.  
  4. #Region " Windows Form Designer generated code "
  5.  
  6. Public Sub New()
  7. MyBase.New()
  8.  
  9. 'This call is required by the Windows Form Designer.
  10. InitializeComponent()
  11.  
  12. 'Add any initialization after the InitializeComponent() call
  13.  
  14. End Sub
  15.  
  16. 'Form overrides dispose to clean up the component list.
  17. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
  18. If disposing Then
  19. If Not (components Is Nothing) Then
  20. components.Dispose()
  21. End If
  22. End If
  23. MyBase.Dispose(disposing)
  24. End Sub
  25.  
  26. 'Required by the Windows Form Designer
  27. Private components As System.ComponentModel.IContainer
  28.  
  29. 'NOTE: The following procedure is required by the Windows Form Designer
  30. 'It can be modified using the Windows Form Designer.
  31. 'Do not modify it using the code editor.
  32. Friend WithEvents Button1 As System.Windows.Forms.Button
  33. Friend WithEvents Label1 As System.Windows.Forms.Label
  34. Friend WithEvents Button2 As System.Windows.Forms.Button
  35. Friend WithEvents Label2 As System.Windows.Forms.Label
  36. Friend WithEvents Label3 As System.Windows.Forms.Label
  37. Friend WithEvents Label4 As System.Windows.Forms.Label
  38. Friend WithEvents btna As System.Windows.Forms.Button
  39. Friend WithEvents btnm As System.Windows.Forms.Button
  40. Friend WithEvents btnl As System.Windows.Forms.Button
  41. Friend WithEvents btnk As System.Windows.Forms.Button
  42. Friend WithEvents btnj As System.Windows.Forms.Button
  43. Friend WithEvents btni As System.Windows.Forms.Button
  44. Friend WithEvents btng As System.Windows.Forms.Button
  45. Friend WithEvents btnf As System.Windows.Forms.Button
  46. Friend WithEvents btne As System.Windows.Forms.Button
  47. Friend WithEvents btnd As System.Windows.Forms.Button
  48. Friend WithEvents btnc As System.Windows.Forms.Button
  49. Friend WithEvents btnb As System.Windows.Forms.Button
  50. Friend WithEvents btnu As System.Windows.Forms.Button
  51. Friend WithEvents btnt As System.Windows.Forms.Button
  52. Friend WithEvents btns As System.Windows.Forms.Button
  53. Friend WithEvents btnr As System.Windows.Forms.Button
  54. Friend WithEvents btnq As System.Windows.Forms.Button
  55. Friend WithEvents btnp As System.Windows.Forms.Button
  56. Friend WithEvents btno As System.Windows.Forms.Button
  57. Friend WithEvents btnn As System.Windows.Forms.Button
  58. Friend WithEvents btny As System.Windows.Forms.Button
  59. Friend WithEvents btnx As System.Windows.Forms.Button
  60. Friend WithEvents btnw As System.Windows.Forms.Button
  61. Friend WithEvents btnv As System.Windows.Forms.Button
  62. Friend WithEvents btnz As System.Windows.Forms.Button
  63. Friend WithEvents btnh As System.Windows.Forms.Button
  64. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
  65. Me.Button1 = New System.Windows.Forms.Button()
  66. Me.Label1 = New System.Windows.Forms.Label()
  67. Me.Button2 = New System.Windows.Forms.Button()
  68. Me.btna = New System.Windows.Forms.Button()
  69. Me.btnm = New System.Windows.Forms.Button()
  70. Me.btnl = New System.Windows.Forms.Button()
  71. Me.btnk = New System.Windows.Forms.Button()
  72. Me.btnj = New System.Windows.Forms.Button()
  73. Me.btni = New System.Windows.Forms.Button()
  74. Me.btnh = New System.Windows.Forms.Button()
  75. Me.btng = New System.Windows.Forms.Button()
  76. Me.btnf = New System.Windows.Forms.Button()
  77. Me.btne = New System.Windows.Forms.Button()
  78. Me.btnd = New System.Windows.Forms.Button()
  79. Me.btnc = New System.Windows.Forms.Button()
  80. Me.btnb = New System.Windows.Forms.Button()
  81. Me.btny = New System.Windows.Forms.Button()
  82. Me.btnx = New System.Windows.Forms.Button()
  83. Me.btnw = New System.Windows.Forms.Button()
  84. Me.btnv = New System.Windows.Forms.Button()
  85. Me.btnu = New System.Windows.Forms.Button()
  86. Me.btnt = New System.Windows.Forms.Button()
  87. Me.btns = New System.Windows.Forms.Button()
  88. Me.btnr = New System.Windows.Forms.Button()
  89. Me.btnq = New System.Windows.Forms.Button()
  90. Me.btnp = New System.Windows.Forms.Button()
  91. Me.btno = New System.Windows.Forms.Button()
  92. Me.btnn = New System.Windows.Forms.Button()
  93. Me.btnz = New System.Windows.Forms.Button()
  94. Me.Label2 = New System.Windows.Forms.Label()
  95. Me.Label3 = New System.Windows.Forms.Label()
  96. Me.Label4 = New System.Windows.Forms.Label()
  97. Me.SuspendLayout()
  98. '
  99. 'Button1
  100. '
  101. Me.Button1.Location = New System.Drawing.Point(8, 200)
  102. Me.Button1.Name = "Button1"
  103. Me.Button1.Size = New System.Drawing.Size(80, 24)
  104. Me.Button1.TabIndex = 0
  105. Me.Button1.Text = "Start"
  106. '
  107. 'Label1
  108. '
  109. Me.Label1.Location = New System.Drawing.Point(184, 80)
  110. Me.Label1.Name = "Label1"
  111. Me.Label1.Size = New System.Drawing.Size(232, 40)
  112. Me.Label1.TabIndex = 1
  113. '
  114. 'Button2
  115. '
  116. Me.Button2.Location = New System.Drawing.Point(8, 224)
  117. Me.Button2.Name = "Button2"
  118. Me.Button2.Size = New System.Drawing.Size(80, 24)
  119. Me.Button2.TabIndex = 2
  120. Me.Button2.Text = "Exit"
  121. '
  122. 'btna
  123. '
  124. Me.btna.Location = New System.Drawing.Point(56, 256)
  125. Me.btna.Name = "btna"
  126. Me.btna.Size = New System.Drawing.Size(32, 32)
  127. Me.btna.TabIndex = 3
  128. Me.btna.Text = "A"
  129. '
  130. 'btnm
  131. '
  132. Me.btnm.Location = New System.Drawing.Point(440, 256)
  133. Me.btnm.Name = "btnm"
  134. Me.btnm.Size = New System.Drawing.Size(32, 32)
  135. Me.btnm.TabIndex = 4
  136. Me.btnm.Text = "M"
  137. '
  138. 'btnl
  139. '
  140. Me.btnl.Location = New System.Drawing.Point(408, 256)
  141. Me.btnl.Name = "btnl"
  142. Me.btnl.Size = New System.Drawing.Size(32, 32)
  143. Me.btnl.TabIndex = 5
  144. Me.btnl.Text = "L"
  145. '
  146. 'btnk
  147. '
  148. Me.btnk.Location = New System.Drawing.Point(376, 256)
  149. Me.btnk.Name = "btnk"
  150. Me.btnk.Size = New System.Drawing.Size(32, 32)
  151. Me.btnk.TabIndex = 6
  152. Me.btnk.Text = "K"
  153. '
  154. 'btnj
  155. '
  156. Me.btnj.Location = New System.Drawing.Point(344, 256)
  157. Me.btnj.Name = "btnj"
  158. Me.btnj.Size = New System.Drawing.Size(32, 32)
  159. Me.btnj.TabIndex = 7
  160. Me.btnj.Text = "J"
  161. '
  162. 'btni
  163. '
  164. Me.btni.Location = New System.Drawing.Point(312, 256)
  165. Me.btni.Name = "btni"
  166. Me.btni.Size = New System.Drawing.Size(32, 32)
    <