PDA

View Full Version : My first VB program



Jaepheth
April 11th 2009, 04:08 AM
Well, I'm still trying to get my first actuary position, but it seems that VB is a plus, so I've set out to teach myself.

I just finished my first program. It allows you to practice and evaluate your 10-key proficiency.

It has a lot of room for improvement, and I'm not 100% sure the KSPH are accurate, but I quite like it for a first program.

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

NoMoreExams
April 11th 2009, 10:58 AM
Well, I'm still trying to get my first actuary position, but it seems that VB is a plus, so I've set out to teach myself.

I just finished my first program. It allows you to practice and evaluate your 10-key proficiency.

It has a lot of room for improvement, and I'm not 100% sure the KSPH are accurate, but I quite like it for a first program.

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

Most people wouldn't click on an executable...

Apollon
April 11th 2009, 11:46 AM
You could submit the program to softpedia and then give us the link to the softpedia page that has your program.

Jaepheth
April 11th 2009, 04:00 PM
Well, I don't have enough FTP sources and don't have a personal website, so I can't fill out all the required fields in Softpedia's submission form.

But I can post the source code and a screenshot:
http://img26.imageshack.us/img26/7608/screen10key.jpg



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_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