Visual Basic Tutorial - #3 - Calculator Tutorial

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
2,786
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Sep 8, 2010

This Visual Basic tutorial is for beginners and starters of the language.

All right, here we will learn how to build a simple and small Visual Basic Calculator. We're learning about a few new things today like converting a string to a double and how to use +, -, x and :.

If you like my video's, please comment rate and subscribe!

---SCRIPT SPOILER---


Private Sub cmdDevide_Click()



Dim Number1S As String
Dim Number1 As Double

Number1S = txtNumber1.Text
Number1 = Val(Number1S)

Dim Number2S As String
Dim Number2 As Double

Number2S = txtNumber2.Text
Number2 = Val(Number2S)

Dim Answer As Double
Dim AnswerS As String

Answer = Number1 / Number2
AnswerS = Str(Answer)
txtAnswer.Text = CDbl(Answer)
txtAnswer.Text = AnswerS
End Sub

Private Sub cmdMinus_Click()



Dim Number1S As String
Dim Number1 As Double

Number1S = txtNumber1.Text
Number1 = Val(Number1S)

Dim Number2S As String
Dim Number2 As Double

Number2S = txtNumber2.Text
Number2 = Val(Number2S)

Dim Answer As Double
Dim AnswerS As String

Answer = Number1 - Number2
AnswerS = Str(Answer)
txtAnswer.Text = CDbl(Answer)
txtAnswer.Text = AnswerS
End Sub

Private Sub cmdMultiply_Click()



Dim Number1S As String
Dim Number1 As Double

Number1S = txtNumber1.Text
Number1 = Val(Number1S)

Dim Number2S As String
Dim Number2 As Double

Number2S = txtNumber2.Text
Number2 = Val(Number2S)

Dim Answer As Double
Dim AnswerS As String

Answer = Number1 * Number2
AnswerS = Str(Answer)
txtAnswer.Text = CDbl(Answer)
txtAnswer.Text = AnswerS
End Sub

Private Sub cmdPlus_Click()



Dim Number1S As String
Dim Number1 As Double

Number1S = txtNumber1.Text
Number1 = Val(Number1S)

Dim Number2S As String
Dim Number2 As Double

Number2S = txtNumber2.Text
Number2 = Val(Number2S)

Dim Answer As Double
Dim AnswerS As String

Answer = Number1 + Number2
AnswerS = Str(Answer)
txtAnswer.Text = CDbl(Answer)
txtAnswer.Text = AnswerS

End Sub

  • likes, 6 dislikes

Link to this comment:

Share to:

Uploader Comments (TeachMeUp)

  • I don't understand why you use strings and Cdbl function for such an easy example? Could you explain the reasoning? Thanks, good video

  • @AndyBCankaya Because new users have to know what these functions do, ofcourse these codes I am writing can be very short and simple, but new users have to know what is happening and what functions there are in VB. That's why I chose to use these functions and make it longer than is needed!

    And thanks!

see all

All Comments (8)

Sign In or Sign Up now to post a comment!
  • This tutorial is the BEST VB tutorial I have EVER seen. And...I absolutely LOVE the BACKGROUND of your computer! It is HOT!

  • @mahmoodiraqi I was fastin :(

  • @FaoodX wats so offensive about the background? its freaking nice !

  • thanx but just reported for the offensive background!

  • 10Q

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more