vb.net 2010 blind typing game-VBForums
Results 1 to 2 of 2

Thread: vb.net 2010 blind typing game

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2009
    Posts
    760

    vb.net 2010 blind typing game

    open a new windows form project
    add from the tool box to the form the controls :
    picturbox
    label1
    textbox1
    label2 textbox2 textbox3
    label3 label4 button1

    timer1

    rightclick form , view code, paste :
    Code:
    Imports System.IO
    Public Class Form1
        Dim timecounter As Integer
        Dim pictureCounter As Integer = 0
        Dim currentHighScore As Integer = 0
        Dim pathSupreme As String
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim open As New OpenFileDialog
            open.ShowDialog()
            pathSupreme = open.FileName
            pathSupreme = pathSupreme.Substring(0, pathSupreme.LastIndexOf("\") + 1)
            Dim di As New IO.DirectoryInfo(pathSupreme)
            Dim aryFi As IO.FileInfo() = di.GetFiles("*.*")
            Dim fi As IO.FileInfo
            Dim c As Integer = 0
            If File.Exists(pathSupreme & "highScore.txt") Then
                Label2.Text = File.ReadAllText(pathSupreme & "highScore.txt")
            Else
                Label2.Text = 0
            End If
            For Each fi In aryFi
                Try
                    If fi.Extension = ".txt" Then
                        File.Delete(fi.FullName)
                    End If
                    My.Computer.FileSystem.RenameFile(fi.FullName, c.ToString & ".bmp")
                Catch ex As Exception
    
                End Try
                c += 1
            Next
            File.WriteAllText(pathSupreme & "highScore.txt", Label2.Text)
        End Sub
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            TextBox2.Text = 10 'default time limit in seconds
            TextBox3.Text = 5 ' default char per word
            timecounter = 10
            Label3.Text = currentHighScore
            Label2.Text = "0"
            Label4.Text = 0
            Label1.Text = " PRESS BUTTON TO SELECT MANGA FOLDER, CLICK TOP TEXT BOX AND PRESS ENTER TO START (ON CAPSLOCK)"
        End Sub
    
        Private Sub TextBox2_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox2.KeyUp
            If e.KeyCode = Keys.Left Then
                TextBox2.Text -= 1
            ElseIf e.KeyCode = Keys.Right Then
                TextBox2.Text += 1
            End If
            If TextBox2.Text < 1 Then
                TextBox2.Text = 1
            End If
            timecounter = TextBox2.Text
        End Sub
    
        Private Sub TextBox3_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox3.KeyUp
            If e.KeyCode = Keys.Left Then
                TextBox3.Text -= 1
            ElseIf e.KeyCode = Keys.Right Then
                TextBox3.Text += 1
            End If
            If TextBox3.Text < 1 Then
                TextBox3.Text = 1
            End If
        End Sub
    
        Private Sub TextBox1_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp
            If e.KeyCode = Keys.Escape Then
                Timer1.Enabled = False
                MsgBox("GAME ENDED")
            ElseIf e.KeyCode = Keys.Enter Then
                TextBox1.Clear()
                pictureCounter = 0
                currentHighScore = 0
                Timer1.Enabled = True
                timecounter = TextBox2.Text
                Label1.Text = ""
                Dim random As New Random()
                Dim t1 As Byte
                t1 = TextBox3.Text
                For index = 1 To t1
                    Label1.Text &= Chr(random.Next(65, 91))
                Next
            ElseIf Label1.Text = TextBox1.Text And Timer1.Enabled Then
                TextBox1.Clear()
                Label1.Text = ""
                Dim random As New Random()
                Dim t1 As Byte
                t1 = TextBox3.Text
                For index = 1 To t1
                    Label1.Text &= Chr(random.Next(65, 91))
                Next
                currentHighScore += 1
                Label3.Text = currentHighScore
                If Label2.Text < currentHighScore Then
                    Label2.Text = currentHighScore
                    File.WriteAllText(pathSupreme & "highScore.txt", Label2.Text)
                End If
                If Not File.Exists(pathSupreme & currentHighScore.ToString() & ".bmp") Then
                    pictureCounter = 0
                Else
                    pictureCounter += 1
                End If
                PictureBox1.ImageLocation = pathSupreme & currentHighScore.ToString() & ".bmp"
                timecounter = TextBox2.Text
            ElseIf Timer1.Enabled = False Then
                TextBox1.Clear()
                MsgBox("press enter to start or escape to stop")
            End If
        End Sub
    
        Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            timecounter -= 1
            If timecounter = 0 Then
                Timer1.Enabled = False
                Label1.Text = "game ended"
            End If
            Label4.Text = timecounter
        End Sub
    End Class
    to play fist click the button and select a file from a folder containing pictures a manga , or a comic picture collection
    time to amp up the beef

  2. #2
    New Member
    Join Date
    Jul 2012
    Posts
    1

    Re: vb.net 2010 blind typing game

    i think this converter is cool, but the format isnīt
    so thereīs my question:
    "How can i convert it into another Format e.g. to a JPG?"

    greats Mr.Unbekannt2.0

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.