Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 hangman help VB
Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
programmer1337




PostPosted: Sat Dec 10, 2011 8:46 pm   Post subject: hangman help VB

ummm yea so i have a fileIO and i have 25 words in it and it randomly generates the words picked and puts underscores for how many letters there are but all i need is to make the other button be able to recognize the actual word it generated, and how to make a certain if statement that checks if the letter you picked is in the actual word.
code:
Imports System.IO
Public Class Form1
    Dim read As String
    Dim read1 As String
    Dim read2 As String
    Dim read3 As String
    Dim read4 As String
    Dim read5 As String
    Dim read6 As String
    Dim read7 As String
    Dim read8 As String
    Dim read9 As String
    Dim read10 As String
    Dim read11 As String
    Dim read12 As String
    Dim read13 As String
    Dim read14 As String
    Dim read15 As String
    Dim read16 As String
    Dim read17 As String
    Dim read18 As String
    Dim read19 As String
    Dim read20 As String
    Dim read21 As String
    Dim read22 As String
    Dim read23 As String
    Dim read24 As String
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim readFile As StreamReader = New StreamReader("words.txt")
        Dim phrase As String
        Dim phrase1 As String
        Dim phrase2 As String
        Dim phrase3 As String
        Dim phrase4 As String
        Dim phrase5 As String
        Dim phrase6 As String
        Dim phrase7 As String
        Dim rndInt As Integer
        Randomize()
        rndInt = Int(Rnd() * 25) + 1
        read = readFile.ReadLine
        read1 = readFile.ReadLine
        read2 = readFile.ReadLine
        read3 = readFile.ReadLine
        read4 = readFile.ReadLine
        read5 = readFile.ReadLine
        read6 = readFile.ReadLine
        read7 = readFile.ReadLine
        read8 = readFile.ReadLine
        read9 = readFile.ReadLine
        read10 = readFile.ReadLine
        read11 = readFile.ReadLine
        read12 = readFile.ReadLine
        read13 = readFile.ReadLine
        read14 = readFile.ReadLine
        read15 = readFile.ReadLine
        read16 = readFile.ReadLine
        read17 = readFile.ReadLine
        read18 = readFile.ReadLine
        read19 = readFile.ReadLine
        read20 = readFile.ReadLine
        read21 = readFile.ReadLine
        read22 = readFile.ReadLine
        read23 = readFile.ReadLine
        read24 = readFile.ReadLine
        If rndInt = 1 Then
            phrase = read
        ElseIf rndInt = 2 Then
            phrase = read1
        ElseIf rndInt = 3 Then
            phrase = read2
        ElseIf rndInt = 4 Then
            phrase = read3
        ElseIf rndInt = 5 Then
            phrase = read4
        ElseIf rndInt = 6 Then
            phrase = read5
        ElseIf rndInt = 7 Then
            phrase = read6
        ElseIf rndInt = 8 Then
            phrase = read7
        ElseIf rndInt = 9 Then
            phrase = read8
        ElseIf rndInt = 10 Then
            phrase = read9
        ElseIf rndInt = 11 Then
            phrase = read10
        ElseIf rndInt = 12 Then
            phrase = read11
        ElseIf rndInt = 13 Then
            phrase = read12
        ElseIf rndInt = 14 Then
            phrase = read13
        ElseIf rndInt = 15 Then
            phrase = read14
        ElseIf rndInt = 16 Then
            phrase = read15
        ElseIf rndInt = 17 Then
            phrase = read16
        ElseIf rndInt = 18 Then
            phrase = read17
        ElseIf rndInt = 19 Then
            phrase = read18
        ElseIf rndInt = 20 Then
            phrase = read19
        ElseIf rndInt = 21 Then
            phrase = read20
        ElseIf rndInt = 22 Then
            phrase = read21
        ElseIf rndInt = 23 Then
            phrase = read22
        ElseIf rndInt = 24 Then
            phrase = read23
        ElseIf rndInt = 25 Then
            phrase = read24
        End If
        Dim phrase8 As String
        Dim phrase9 As String
        phrase1 = "_ " & "_" & " _"
        phrase2 = "_ " & "_" & " _" & " _"
        phrase3 = "_ " & "_" & " _" & " _" & " _"
        phrase4 = "_ " & "_" & " _" & " _" & " _" & " _"
        phrase5 = "_ " & "_" & " _" & " _" & " _" & " _" & " _"
        phrase6 = "_ " & "_" & " _" & " _" & " _" & " _" & " _" & " _"
        phrase7 = "_ " & "_" & " _" & " _" & " _" & " _" & " _" & " _" & " _"
        phrase8 = "_ " & "_" & " _" & " _" & " _" & " _" & " _" & " _" & " _" & " _"
        phrase9 = "_ " & "_" & " _" & " _" & " _" & " _" & " _" & " _" & " _" & " _" & " _"
        If phrase.Length = 3 Then
            txtBox.Text = phrase1
        ElseIf phrase.Length = 4 Then
            txtBox.Text = phrase2
        ElseIf phrase.Length = 5 Then
            txtBox.Text = phrase3
        ElseIf phrase.Length = 6 Then
            txtBox.Text = phrase4
        ElseIf phrase.Length = 7 Then
            txtBox.Text = phrase5
        ElseIf phrase.Length = 8 Then
            txtBox.Text = phrase6
        ElseIf phrase.Length = 9 Then
            txtBox.Text = phrase7
        ElseIf phrase.Length = 10 Then
            txtBox.Text = phrase8
        ElseIf phrase.Length = 11 Then
            txtBox.Text = phrase9
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim count As Integer
        Dim guess As Char
        Do
            guess = InputBox("Enter a letter to guess")
            If guess = "a" And phrase.Substring(0, 0) = "a" Then

            End If
            loop until
    End Sub
End Class
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: