Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Calculator tutorial! Visual Basic.

Open up Visual Studio, and start a new project.
Create a Visual Basic program & make it a "Windows form application".
-
What you need to do:
Drop in 3 labels.
First one: "Enter first number"
Second one: "Enter second number"
and the third one: "Result".
Drop in 4 buttons and name them
1: "Add"
2: "Subtract"
3: "Multiply"
and 4: "Divide"
Then just drop in 3 text boxes.
Put the first label at the top, with a text box under it.
Drop the second label under the first textbox and another text box under the second label.
Then just put the four buttons how ever you like under.
At the bottom put the result label & textbox in together.
Make sure that in the last textbox in the settings you turn ReadOnly to True.
-
iNcase you can't keep up, here's a photo
http ://postimg. org/image/6wb07x90n/
-
Time for the coding.
Double tap all the buttons, then close the tabs and go back to the original form.
Double tap the form and that should take you to this
http ://postimg. org/image/ih8bd28r7/
-
Under Button1_Click you have to enter in the following code
PHP Code

<?php 
Dim a
, b, r As Integer
a 
= Val(Textbox1.Text)
b = Val(Textbox2.Text)
r = a + b
Textbox3
.Text = r 
Dim a, b, r As Integer // This tells the program that textbox 1 = A, textbox 2 = b and textbox 3 = result/r.
-
For button2_Click enter the same code except change a + b to a - b.
:
PHP Code

<?php 
Dim a
, b, r As Integer
a 
= Val(Textbox1.Text)
b = Val(Textbox2.Text)
r = a - b
Textbox3
.Text = r 
-
Button3_click
PHP Code

<?php 
Dim a
, b, r As Integer
a 
= Val(Textbox1.Text)
b = Val(Textbox2.Text)
r = a * b
Textbox3
.Text = r 
-
PHP Code

<?php 
Dim a
, b, r As Integer
a 
= Val(Textbox1.Text)
b = Val(Textbox2.Text)
r = a / b
Textbox3
.Text = r 
-
Full code:
PHP Code

<?php 
Public Class Form1

    
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

    
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim a
, b, r As Integer
        a 
= Val(TextBox1.Text)
        
b = Val(TextBox2.Text)
        
r = a + b
        TextBox3
.Text = r
    End Sub

    
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim a
, b, r As Integer
        a 
= Val(TextBox1.Text)
        
b = Val(TextBox2.Text)
        
r = a - b
        TextBox3
.Text = r
    End Sub

    
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Dim a
, b, r As Integer
        a 
= Val(TextBox1.Text)
        
b = Val(TextBox2.Text)
        
r = a * b
        TextBox3
.Text = r
    End Sub

    
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        Dim a
, b, r As Integer
        a 
= Val(TextBox1.Text)
        
b = Val(TextBox2.Text)
        
r = a / b
        TextBox3
.Text = r
    End Sub
End 
Class 
-
END RESULT:
http ://postimg. org/image/vjbx2lp7r/
Thanks for reading :)
If you have any questions (I'm not a pro) feel free to ask! :)
Please leave some feedback if this helped you
Not the most advanced of tutorials, and I'm not overly sure what will happen if someone enters something that's not a number into the boxes, but good start to the forum 🤝

Scratch that, source here: https://tech9tutorialz.wordpress.com/201...ual-basic/
Isn't that the site that copies everything off HackForums?
I didn't copy off anywhere.
(Sep 16, 2015 03:56 AM)Cece Drake Wrote:  Isn't that the site that copies everything off HackForums?
I didn't copy off anywhere.

I wouldn't know, I just saw the exact same text on another website.
(Sep 16, 2015 05:00 AM)Josh‎ Wrote:  I wouldn't know, I just saw the exact same text on another website.

It is.
Go through the posts and it has everything that HF has
You copied this from another website -.-

And This is not the BEST tut in the world.
I didn't copy.
please provide a link
Lol, what if someone wants to calculate decimals as well? And why did you include empty form load events lol?
Thanks, I have been looking for a calculator tutorial everywhere!
(Sep 17, 2015 02:48 PM)LijpeMD Wrote:  Thanks, I have been looking for a calculator tutorial everywhere!

You didn't know what basic math is? +, -, x, /

You can use an integer to equal math problems. Hope you learned that.
(Sep 17, 2015 03:17 PM)Jackie Chun Wrote:  You didn't know what basic math is? +, -, x, /

You can use an integer to equal math problems. Hope you learned that.

Your a fucking idiot. You do not know what scarsam is?


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Source] by SIM-5420967May 26, 2024 09:50 AM 2 367 May 26, 2024 09:50 AM
Last Post: xiaowanga8
[.NET] by BladabindiMay 17, 2023 12:20 AM 1 177 May 17, 2023 12:20 AM
Last Post: NyQuil
[.NET] by DrpriyaOct 4, 2022 11:17 PM 4 328 Oct 4, 2022 11:17 PM
Last Post: LeetSpeed