HangMan VB

Discussion in 'Programming General' started by stui, Nov 2, 2011.

HangMan VB
  1. Unread #1 - Nov 2, 2011 at 8:02 PM
  2. stui
    Joined:
    Jan 15, 2011
    Posts:
    3,798
    Referrals:
    5
    Sythe Gold:
    0

    stui Attend 500M Daily Drops, join #Smokin_Dice
    Banned

    HangMan VB

    hey im making a hangman game for a school assignment and was wondering how to import the word list into the array and then read the words in ? so far the only code i have is

    Onclick (....)

    ButtonA.Enabled = False ( so when they have already tried 1 it is disabled
    ButtonA.Visible = False (so once they click it, it dissapears
     
  3. Unread #2 - Nov 3, 2011 at 7:52 AM
  4. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    HangMan VB

    Hey bro, are you using vb.net or vb6?
    If you're not sure just code into the code window and if you see shit like:
    Code:
    private sub button1_click(sender as something, e as eventargs) handles button1.click
    
    end sub
    vb6 is like:
    Code:
    private sub command1_click()
    
    end sub
    judging by what you've said with the 'onclick' event i think you have .net so hopefully i'm correct.

    Make a new project and add this code, then add a button to the form called button1 and play around with it, it's pretty straight forward.
    Code:
    Public Class Form1
    
        Private lstWord As New List(Of String)
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
            'add words to the list
            lstWord.Add("banana")
            lstWord.Add("apple")
            lstWord.Add("covey")
    
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
            'display all the words in the list
            Dim intloop As Integer
            For intloop = 0 To lstWord.Count - 1
                MsgBox(lstWord(intloop))
            Next
    
        End Sub
    
        Private Function IsWord(ByVal strWord As String) As Boolean
    
            'checks to see if the defined word is in the list.
            'if you want to make it case INSENSITIVE use 'lcase(strWord)' instead of 'strWord'
            If lstWord.Contains(strWord) Then
                Return True
            Else
                Return False
            End If
    
        End Function
    
    End Class
     
  5. Unread #3 - Nov 4, 2011 at 6:53 AM
  6. stui
    Joined:
    Jan 15, 2011
    Posts:
    3,798
    Referrals:
    5
    Sythe Gold:
    0

    stui Attend 500M Daily Drops, join #Smokin_Dice
    Banned

    HangMan VB

    What about if i wanted to import it from a text file e.g. i have a word list of like 100 called words.txt?? and yer its in .net
     
  7. Unread #4 - Nov 4, 2011 at 6:56 AM
  8. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    HangMan VB

    straight from google
    Code:
    Dim FILE_NAME As String = "C:\Users\Owner\Documents\test.txt"
    
    Dim objReader As New System.IO.StreamReader(FILE_NAME)
    
    Dim strWords as string
    
    strwords = objReader.ReadToEnd
    
    objReader.Close()
    then loop through strwords adding them to the list.
     
  9. Unread #5 - Nov 4, 2011 at 7:41 AM
  10. stui
    Joined:
    Jan 15, 2011
    Posts:
    3,798
    Referrals:
    5
    Sythe Gold:
    0

    stui Attend 500M Daily Drops, join #Smokin_Dice
    Banned

    HangMan VB

    ok thanks so much :))))
     
< How to get started on making a very simple bot... | Someone help me please? >

Users viewing this thread
1 guest


 
 
Adblock breaks this site