The Geek Forum

  • April 29, 2024, 04:30:14 AM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

News:

Due to the prolific nature of these forums, poster aggression is advised.

*

Recent Forum Posts

Shout Box

Members
Stats
  • Total Posts: 129570
  • Total Topics: 7159
  • Online Today: 273
  • Online Ever: 1013
  • (January 12, 2023, 01:18:11 AM)

Author Topic: My first Visual Basic 2008 Program  (Read 3540 times)

Jaepheth

  • Computer Whore
  • **
  • Coolio Points: +114/-5
  • Offline Offline
  • Gender: Male
  • Posts: 348
    • View Profile
My first Visual Basic 2008 Program
« on: April 11, 2009, 03:59:40 AM »

Just finished the first release of my very first functioning program written in Visual Basic!

It's a program that lets you practice and evaluate your proficiency with the 10 key.

I know, it has a lot of room for improvement.



It won't let me upload a .exe file, so I changed the extension to jpg.

save as and then rename it (if you trust it's not a virus, which it's not.)
« Last Edit: April 11, 2009, 03:41:12 PM by Jaepheth »
Logged

I'm sorry, but the number you have dialed is imaginary. Please rotate the phone by 90 degrees and try again.

Jaepheth

  • Computer Whore
  • **
  • Coolio Points: +114/-5
  • Offline Offline
  • Gender: Male
  • Posts: 348
    • View Profile
Re: My first Visual Basic 2008 Program
« Reply #1 on: April 11, 2009, 04:16:04 AM »

Rapid share link
http://rapidshare.com/files/219993138/10key.exe.html

And also source:

Code: [Select]
Public Class Form1
    Dim cnt As Integer
    Dim num As Stack(Of Integer)
    Dim clock As Double
    Dim ks As Integer
    Dim err As Integer
    Dim avg As Long
    Dim wins As Integer
    Dim fail As Boolean

    Private Sub Form1_HelpButtonClicked(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles Me.HelpButtonClicked
        MsgBox("This 10key practice program was written by" & Chr(10) & "Jeffrey Wong" & Chr(10) & "Copyright 2009" & Chr(10) & Chr(10) & "Just use the numpad to type the number displayed." & Chr(10) & "No backspacing supported in this version, sorry.", MsgBoxStyle.OkOnly)
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Timer1.Enabled = False
        newgame()
    End Sub
    Private Sub newgame()
        Label5.Text = "Press 's' to stop"
        Label4.Text = "You may begin when ready."
        Label2.Text = "KSPH:"
        Label3.Text = "Accuracy:"
        wins = 0
        fail = False
        clock = 0
        cnt = 1
        Label1.Text = 0
        num = New Stack(Of Integer)
        num.Push(0)
    End Sub
    Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        Select Case e.KeyCode
            Case Keys.NumPad0
                numpress(0)
            Case Keys.NumPad1
                numpress(1)
            Case Keys.NumPad2
                numpress(2)
            Case Keys.NumPad3
                numpress(3)
            Case Keys.NumPad4
                numpress(4)
            Case Keys.NumPad5
                numpress(5)
            Case Keys.NumPad6
                numpress(6)
            Case Keys.NumPad7
                numpress(7)
            Case Keys.NumPad8
                numpress(8)
            Case Keys.NumPad9
                numpress(9)
            Case Keys.S
                If Timer1.Enabled Then
                    Timer1.Enabled = False
                    calc()
                End If
            Case Keys.R
                If Not Timer1.Enabled Then
                    newgame()
                End If
        End Select
    End Sub
    Private Sub numpress(ByVal a)
        If Not Timer1.Enabled Then
            Timer1.Enabled = True
            Label4.Text = ""
        End If
        ks += 1
        Label4.Text = Label4.Text & a
        If Not num.Count = 0 And Not a = num.Pop() Then
            err += 1
            fail = True
        End If
        If num.Count = 0 Then
            Label4.Text = ""
            If fail And Not cnt = 1 Then
                cnt -= 1
                wins = 0
                fail = False
            End If
            If Not fail Then
                wins += 1
                If wins = 10 Then
                    Timer1.Enabled = False
                    calc()
                    MsgBox("You Win!", MsgBoxStyle.OkOnly)
                    Exit Sub
                End If
                If Not cnt = 10 And cnt = wins Then
                    cnt += 1
                    wins = 0
                End If
            End If
            newnum(cnt)
        End If
    End Sub
    Private Sub newnum(ByVal c)
        Dim rand As Random = New Random
        For i As Integer = 1 To c Step 1
            num.Push(rand.Next(0, 10))
        Next i
        Dim number As String
        Dim copy As Stack(Of Integer) = New Stack(Of Integer)
        Dim a As Integer
        For i As Integer = 1 To num.Count Step 1
            a = num.Pop()
            copy.Push(a)
            number = number & a
        Next i
        For i As Integer = 1 To copy.Count Step 1
            num.Push(copy.Pop)
        Next i
        Label1.Text = number
    End Sub
    Private Sub calc()
        Dim ksph As Double = (ks / (clock / (10 * 60 * 60)))
        Label2.Text = "KSPH: " & System.Math.Round(ksph, 3)
        Dim acc As Double = 100 * ((ks - err) / ks)
        Label3.Text = "Accuracy:  " & System.Math.Round(acc, 3) & "%"
        ks = 1
        err = 0
        avg = 0
        clock = 0
        Label5.Text = "Press 'r' to restart"
    End Sub
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        clock = clock + 1
    End Sub
End Class
Logged

I'm sorry, but the number you have dialed is imaginary. Please rotate the phone by 90 degrees and try again.

xolik

  • King of the Geekery
  • Hacker
  • ****
  • Coolio Points: +541/-25
  • Offline Offline
  • Gender: Male
  • Posts: 5176
  • HAY GUYS
    • View Profile
Re: My first Visual Basic 2008 Program
« Reply #2 on: April 13, 2009, 05:49:53 PM »

Keylogger ITT




 :-D
Logged
Barium: What you do if CPR fails.

=-=-=-=-=-=-=-=-=-=-=
[The Fade^C Compound]
-=-=-=-=-=-=-=-=-=-=-

Jaepheth

  • Computer Whore
  • **
  • Coolio Points: +114/-5
  • Offline Offline
  • Gender: Male
  • Posts: 348
    • View Profile
Re: My first Visual Basic 2008 Program
« Reply #3 on: April 13, 2009, 11:55:27 PM »

Logged

I'm sorry, but the number you have dialed is imaginary. Please rotate the phone by 90 degrees and try again.

WickedWizard

  • Jail Bait
  • *
  • Coolio Points: +9/-13
  • Offline Offline
  • Gender: Male
  • Posts: 67
    • View Profile
Re: My first Visual Basic 2008 Program
« Reply #4 on: April 18, 2009, 01:27:28 PM »

Nice first program.
Logged
The Characters and incidents portrayed and the names used
are fictitious and any similarity to the names, characters,
or history of any person is entirely accidental and
unintentional.
                        Signed RICHARD M. NIXON