9 Replies - 467 Views - Last Post: 02 May 2019 - 08:13 AM Rate Topic: -----

#1 beastmode21   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 08-April 19

making a hang man game need help making it work.

Posted 01 May 2019 - 08:54 AM

Public Class form1
    Dim amountofbadguesses As Integer
    Dim wordlist(20) As String
    Dim hintlist(20) As String
    Dim randomNumber, lengthword As Integer
    Dim letter As String

    Private Property Text1(y As Integer) As Object
        Get
            Return _Text1 705767
        End Get
        Set(value As Object)
            _text1 = value
        End Set
    End Property

    Private Sub Button27_Click(sender As System.Object, e As System.EventArgs) Handles Button27.Click
        End
    End Sub

    Private Sub Button29_Click(sender As System.Object, e As System.EventArgs) Handles NW.Click
        Check1.Visible = True
        For y = 0 To 11
            Text1.Text = False
            Text1.Text = ""
        Next y

        randomNumber = Int(Rnd() * 20) 'eventually needs to be changed
        Print(randomNumber, wordlist(randomNumber))
        lengthword = Len(wordlist(randomNumber))
        'show hint

        For y = 0 To lengthword - 1
            Text1.Visible = True
        Next y
        p = InStr(1, wordlist(randomNumber), " ")
        If p <> 0 Then
            Text1.Text = " "
        End If
    End Sub

    Private Sub Button28_Click(sender As System.Object, e As System.EventArgs) Handles Hint.Click

        If Check1.Value = 1 Then
            MsgBox(hintlist(randomNumber))
        End If
        Check1.Value = 0

        Check1.Visible = False

    End Sub

    Private Function p() As Integer
        Throw New NotImplementedException
    End Function

    Private Function Check1() As Object
        Throw New NotImplementedException
    End Function

End Class

Private function(Index As Integer, e As EventArgs) handles mybase.command1_click

    letter = Command1(Index).Caption
    Call checkletter()

End Function
Private Function(sender As Object, e As EventArgs) Handles mybase.load

    Randomize()
    wordlist(0) = "pencil sharpener"
    wordlist(1) = "workbook"
    wordlist(2) = "ruler"
    wordlist(3) = "calculator"
    wordlist(4) = "binder"
    wordlist(5) = "notebook"
    wordlist(6) = "pencil"
    wordlist(7) = "pen"
    wordlist(8) = "textbook"
    wordlist(9) = "chalk board"
    wordlist(10) = "paper"
    wordlist(11) = "folder"
    wordlist(12) = "desk"
    wordlist(13) = "chair"
    wordlist(14) = "computer"
    wordlist(15) = "student"
    wordlist(16) = "teacher"
    wordlist(17) = "chalk"
    wordlist(18) = "keyboard"
    wordlist(19) = "assignment book"

    hintlist(0) = "something to sharpen your pencil with"
    hintlist(1) = "activities in book form"
    hintlist(2) = "measures objects"
    hintlist(3) = "calculates math problems"
    hintlist(4) = "used to store papers or folders in"
    hintlist(5) = "you take notes in this"
    hintlist(6) = "you use this to write"
    hintlist(7) = "you use this to write"
    hintlist(8) = "gives information on a certain subject"
    hintlist(9) = "teacher writes on this"
    hintlist(10) = "something you do assignments on"
    hintlist(11) = "you store papers in this"
    hintlist(12) = "you use this to write on"
    hintlist(13) = "you sit on this"
    hintlist(14) = "a machine that helps you out with various activities"
    hintlist(15) = "the people that teachers teach"
    hintlist(16) = "the person that teaches students"
    hintlist(17) = "you use this to write on the chalkboard"
    hintlist(18) = "you use this to type"
    hintlist(19) = "used to keep track of assignments"

End Function
Public Sub(sender As Object, e As EventArgs) Handles mybase.checkletter

    Dim guess As Boolean
    guess = False
    Dim p, start As Integer
    start = 1
    p = 0
    For y = 1 To lengthword
        p = InStr(start, wordlist(randomNumber), letter, 1)
        start = p + 1
        If p > 0 Then
            guess = True
            Text1(p - 1).Text = letter
        End If
    Next y
    'if you miss it then it will add parts to hangman add here
    'If guess = False Then
    'count
    If guess = False Then
        amountofbadguesses = amountofbadguesses + 1
        Select Case amountofbadguesses
            Case 1
                PictureBox1.Visible = True
            Case 2
                PictureBox2.Visible = True
            Case 3
                PictureBox3.Visible = True
            Case 4
                PictureBox4.Visible = True
            Case 5
                PictureBox5.Visible = True
            Case 6
                PictureBox6.Visible = True
                amountofbadguesses = 0

        End Select

    End If

    If Image6.Visible = True Then
        For x = 0 To 25
            Command1(x).Enabled = False
        Next x
        Label1.Visible = True
    End If

    For n = 0 To 15
        If Text1(n).Text <> "" Then
            Command1(Index).Enabled = False
            Text1(n).Enabled = False
            Label2.Visible = True
        End If
End Sub
:code:

This post has been edited by modi123_1: 01 May 2019 - 09:20 AM
Reason for edit:: In the future, please use the [code] tag button in the editor.


Is This A Good Question/Topic? 0
  • +

Replies To: making a hang man game need help making it work.

#2 Sheepings   User is offline

  • Senior Programmer
  • member icon

Reputation: 223
  • View blog
  • Posts: 1,260
  • Joined: 05-December 13

Re: making a hang man game need help making it work.

Posted 01 May 2019 - 08:59 AM

Post your problem in detail and don't just do a code dump and expect others to workout your problem.
Was This Post Helpful? 0
  • +
  • -

#3 beastmode21   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 08-April 19

Re: making a hang man game need help making it work.

Posted 01 May 2019 - 09:05 AM

on line 63,69, and 115 i have identified expected and a couple other things idk whats wrong with the code iv been messing with it for a while now.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14994
  • View blog
  • Posts: 59,870
  • Joined: 12-June 08

Re: making a hang man game need help making it work.

Posted 01 May 2019 - 09:21 AM

Agreed - you need to ask a coherent question. I am not certain what you are trying to express is wrong.
Was This Post Helpful? 0
  • +
  • -

#5 Sheepings   User is offline

  • Senior Programmer
  • member icon

Reputation: 223
  • View blog
  • Posts: 1,260
  • Joined: 05-December 13

Re: making a hang man game need help making it work.

Posted 01 May 2019 - 10:33 AM

How are we to know what the problem with the code is. We are not executing it, you are. What errors are you getting on line 63,69, and 115? What have you identified or expected?
Was This Post Helpful? 0
  • +
  • -

#6 beastmode21   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 08-April 19

Re: making a hang man game need help making it work.

Posted 02 May 2019 - 07:06 AM

thats just it idk whats the problem or what needs identified it just has the line under the first ( nothing else.
Was This Post Helpful? 0
  • +
  • -

#7 Sheepings   User is offline

  • Senior Programmer
  • member icon

Reputation: 223
  • View blog
  • Posts: 1,260
  • Joined: 05-December 13

Re: making a hang man game need help making it work.

Posted 02 May 2019 - 07:14 AM

When you hover your mouse on it, what does it say?
Was This Post Helpful? 0
  • +
  • -

#8 beastmode21   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 08-April 19

Re: making a hang man game need help making it work.

Posted 02 May 2019 - 07:42 AM

it says identifier expected.
Was This Post Helpful? 0
  • +
  • -

#9 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14994
  • View blog
  • Posts: 59,870
  • Joined: 12-June 08

Re: making a hang man game need help making it work.

Posted 02 May 2019 - 07:55 AM

010            Return _Text1 705767

that is not how you return a value or a variable. Pick which way you want and use one way.

063  Private function(Index As Integer, e As EventArgs) handles mybase.command1_click

You do not provide a function name.

069 Private Function(sender As Object, e As EventArgs) Handles mybase.load

You do not provide a function name.

115 Public Sub(sender As Object, e As EventArgs) Handles mybase.checkletter

You do not provide a function name.

161    For n = 0 To 15

This doesn't have a 'next' as the error explains.


Make sure to go to tools -> options -> projects & solutions -> vb defaults
Turn on explicit
turn on strict.
Was This Post Helpful? 1
  • +
  • -

#10 Sheepings   User is offline

  • Senior Programmer
  • member icon

Reputation: 223
  • View blog
  • Posts: 1,260
  • Joined: 05-December 13

Re: making a hang man game need help making it work.

Posted 02 May 2019 - 08:13 AM

Some of what has been outlined above will fail under narrowing conversion and other rules, which isn't accepted by OptionStrict being turned on. If line 63 was right, array bounds can't be in a type specifier. To fix, you need to specify the type of function with an As clause at the end of your functions opening line. egg.
Private Function foo(Index As Integer, e As EventArgs) As Integer
And if you want to use the button click events, with custom parameters, I recommend you write custom methods and add your event handlers as you go. You've a lot wrong with your code and likely more errors will appear after enabling OptionStrict.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1