Now, File/New Project and make Windows Application.
Then make enough space to create 16 buttons and 2 text fields. And make sure that Button1 is in number 1's place, Button2 is in number 2's place and so on. Numbers 1-9(for some reason, 0 doesnt seem to work [or desimals]). Change the text of the buttons, Button1 to 1, Button2 to 2... but don't change name, or you have to change the code below.
Then insert then buttons anyway you like and the rest of the buttons, you can rename anyway you want. I renamed them in Finnish, laske; jaettuna....
Make 1 textbox, rename it text1, clear the text1 area, then again make textbox2, rename it to text2, clear the text2 area and just write the following code to buttons:
CODE
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Text1.Text = Text1.Text + "1"
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Text1.Text = Text1.Text + "2"
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Text1.Text = Text1.Text + "3"
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Text1.Text = Text1.Text + "4"
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Text1.Text = Text1.Text + "5"
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Text1.Text = Text1.Text + "6"
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
Text1.Text = Text1.Text + "7"
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
Text1.Text = Text1.Text + "8"
End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
Text1.Text = Text1.Text + "9"
End Sub
Private Sub zero_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Text1.Text = Text1.Text + "0"
End Sub
Text1.Text = Text1.Text + "1"
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Text1.Text = Text1.Text + "2"
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Text1.Text = Text1.Text + "3"
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Text1.Text = Text1.Text + "4"
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Text1.Text = Text1.Text + "5"
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Text1.Text = Text1.Text + "6"
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
Text1.Text = Text1.Text + "7"
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
Text1.Text = Text1.Text + "8"
End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
Text1.Text = Text1.Text + "9"
End Sub
Private Sub zero_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Text1.Text = Text1.Text + "0"
End Sub
Ok, that makes the numbers see on the textbox. Now you need to have 5 buttons for calculating actions. -, +, / and * buttons, with name you prefer. I call them plus (+), miinus(-), jaettuna(/) and kertaa(*). Then insert 4 timers there on form, anywhere. Check the name is Timer1, Timer2, Timer3, and Timer4. After that, write this code to each of the calculating function buttons:
CODE
Private Sub miinus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miinus.Click
Text2.Text = Text1.Text
Text1.Text = ""
Timer1.Enabled = True
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = False
End Sub
Private Sub plus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles plus.Click
Text2.Text = Text1.Text
Text1.Text = ""
Timer1.Enabled = False
Timer2.Enabled = True
Timer3.Enabled = False
Timer4.Enabled = False
End Sub
Private Sub kertaa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kertaa.Click
Text2.Text = Text1.Text
Text1.Text = ""
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = True
Timer4.Enabled = False
End Sub
Private Sub jaettuna_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jaettuna.Click
Text2.Text = Text1.Text
Text1.Text = ""
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = True
End Sub
Text2.Text = Text1.Text
Text1.Text = ""
Timer1.Enabled = True
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = False
End Sub
Private Sub plus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles plus.Click
Text2.Text = Text1.Text
Text1.Text = ""
Timer1.Enabled = False
Timer2.Enabled = True
Timer3.Enabled = False
Timer4.Enabled = False
End Sub
Private Sub kertaa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kertaa.Click
Text2.Text = Text1.Text
Text1.Text = ""
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = True
Timer4.Enabled = False
End Sub
Private Sub jaettuna_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jaettuna.Click
Text2.Text = Text1.Text
Text1.Text = ""
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = True
End Sub
That makes the timer recognize the order. Then this code to "="(I call it laske) button:
CODE
Private Sub laske_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles laske.Click
If Timer1.Enabled = True Then
Text1.Text = Val(Text2.Text) - Val(Text1.Text)
ElseIf Timer2.Enabled = True Then
Text1.Text = Val(Text2.Text) + Val(Text1.Text)
ElseIf Timer3.Enabled = True Then
Text1.Text = Val(Text2.Text) * Val(Text1.Text)
ElseIf Timer4.Enabled = True Then
Text1.Text = Val(Text2.Text) / Val(Text1.Text)
End If
End Sub
If Timer1.Enabled = True Then
Text1.Text = Val(Text2.Text) - Val(Text1.Text)
ElseIf Timer2.Enabled = True Then
Text1.Text = Val(Text2.Text) + Val(Text1.Text)
ElseIf Timer3.Enabled = True Then
Text1.Text = Val(Text2.Text) * Val(Text1.Text)
ElseIf Timer4.Enabled = True Then
Text1.Text = Val(Text2.Text) / Val(Text1.Text)
End If
End Sub
That makes the calculate process. Then add these lines to up:
CODE
Dim lasku As Integer
Now, all we need is the "Clear" button, it's simpler than going to shop:
CODE
Private Sub clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clear.Click
Text1.Text = ""
Text2.Text = ""
End Sub
Text1.Text = ""
Text2.Text = ""
End Sub
All done!
--------------------------------------------------------
IMPORTANT: Feel free to change text or the name of the buttons anyway you like. Just remember, when you change button name, you must change it in the code section too.
This is very simple counter, i dont expect it to be good or anything, but this is the first thing i made for 6 hours thinking
--------------------------------------------------------
My result: http://iltsu.homelinux.org/~microbit/Laskin.zip