Visual Basic .NET Tutorial 4 – How to Create a Simple Calculator in Visual Basic




About this tutorial:

Video duration: 8:25
★★★Top Online Courses From ProgrammingKnowledge ★★★
Python Programming Course ➡️ ⚫️
Java Programming Course ➡️ ⚫️
Bash Shell Scripting Course ➡️ ⚫️
Linux Command Line Tutorials ➡️ ⚫️
C Programming Course ➡️ ⚫️
C++ Programming Course ➡️ ⚫️
PHP Programming Course ➡️…

Post Author: OfficeTutes.com

Apple lover, ICT and LEAN consultant, MS Office lecturer My other website with video tutorials - Tutorials, guides and news for iPhones and iPads

39 thoughts on “Visual Basic .NET Tutorial 4 – How to Create a Simple Calculator in Visual Basic

    Alvin Koay

    (September 17, 2019 - 4:43 am)

    what different of value single and double

    waheedullah hanifi

    (September 17, 2019 - 4:43 am)

    i don't wanna judging you but the variable must be FLOAT. because if someone wanna use decimal number. he/she could do that.

    Mukesh Murmu

    (September 17, 2019 - 4:43 am)

    lack of knowledge.

    polin star

    (September 17, 2019 - 4:43 am)

    Can someone help me how to store data answer rather the numbers that been solved in a Microsoft access database?

    Natanael Zelaya

    (September 17, 2019 - 4:43 am)

    Danke können Sie mir ein Programm mit geraden Zahlen senden

    erickv1977

    (September 17, 2019 - 4:43 am)

    what did he say?

    kandysman86

    (September 17, 2019 - 4:43 am)

    I thought you had to add private before the dim statement before it can be a global statement

    lubna alsadi

    (September 17, 2019 - 4:43 am)

    جميل

    Aldren Villaruel

    (September 17, 2019 - 4:43 am)

    You are so helpful!!! Thank you very much!

    chanchal rajput

    (September 17, 2019 - 4:43 am)

    Your teaching style awesome and my all doubt are clear thank you

    李鑫

    (September 17, 2019 - 4:43 am)

    a lot help !!!! thx soooo much1!!!!!!

    awesomeness

    (September 17, 2019 - 4:43 am)

    how to put the answer inside the text box 3 that i build myself

    Hana Mahad

    (September 17, 2019 - 4:43 am)

    thanks for the help understand now

    L I N Z I

    (September 17, 2019 - 4:43 am)

    lel finally found someone ? , can u make a vid for data types please ?

    hunter the smart

    (September 17, 2019 - 4:43 am)

    i was using this for a custom form that was visual basic inside visual basic (Hb) and this is what the code is:
    Public Class Form1
    Dim t As Integer
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    If TextBox1.Text = "(Hb window" AndAlso TextBox2.Text = "(document" AndAlso TextBox3.Text = "(text" AndAlso TextBox5.Text = "text)" AndAlso TextBox6.Text = "document)" AndAlso TextBox7.Text = "Hb window)" Then
    t = TextBox4.Text
    Form2.Label1.Text = (t)
    Form2.Show()
    End If
    End Sub
    End Class
    but when I type text in textbox4, which I will call "ten" it says that "type ten cannot be converted to integer" could you help?

    Kunj Shah

    (September 17, 2019 - 4:43 am)

    Thanks I am getting it now

    rushi bhatt

    (September 17, 2019 - 4:43 am)

    thank you sir

    Nurul Fatihah

    (September 17, 2019 - 4:43 am)

    what if incomplete values?? how to do that??

    Muhammed Mafas

    (September 17, 2019 - 4:43 am)

    thx a lot for video. my problem is that can i get the "result" in to label without a msgbox.??? please answer me

    jerome palentinos

    (September 17, 2019 - 4:43 am)

    WHY USE COMMA INSTEAD OF DOUBLE VAR

    Christian Santos

    (September 17, 2019 - 4:43 am)

    Nice Video 🙂

    Y Aakash

    (September 17, 2019 - 4:43 am)

    thanks for the video 🙂
    when i subtract a higher value from lower value, answer endup in error. can we showup negative numbers? and how?

    Sam90o Gaming

    (September 17, 2019 - 4:43 am)

    wtf y the hell did I use " , " in place of decimal y it can't show the correct answer by writing 2.33 and 4.22

    Natalie Anderson

    (September 17, 2019 - 4:43 am)

    Help not sure what I did wrong the coding matches exactly as the video

    Number1 = TextBox1.Text error message pops up there saying Text System.InvalidCastException: 'Conversion from string "" to type 'Integer' is not valid.

    'System.InvalidCastException occurred
    HResult=0x80004002
    Message=Conversion from string "" to type 'Integer' is not valid.
    Source=<Cannot evaluate the exception source>
    StackTrace:
    at Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String Value)
    at first_calculator.Form1.TextBox1_TextChanged(Object sender, EventArgs e) in c:usersbabydocumentsvisual studio 2017Projectsfirst calculatorfirst calculatorForm1.vb:line 10
    at System.Windows.Forms.Control.OnTextChanged(EventArgs e)
    at System.Windows.Forms.TextBoxBase.OnTextChanged(EventArgs e)
    at System.Windows.Forms.TextBoxBase.WmReflectCommand(Message& m)
    at System.Windows.Forms.TextBoxBase.WndProc(Message& m)
    at System.Windows.Forms.TextBox.WndProc(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
    at System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam, IntPtr lparam)
    at System.Windows.Forms.Control.ReflectMessageInternal(IntPtr hWnd, Message& m)
    at System.Windows.Forms.Control.WmCommand(Message& m)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
    at System.Windows.Forms.Form.WndProc(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
    at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
    at System.Windows.Forms.Control.DefWndProc(Message& m)
    at System.Windows.Forms.Control.WmKeyChar(Message& m)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.TextBoxBase.WndProc(Message& m)
    at System.Windows.Forms.TextBox.WndProc(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
    at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
    at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
    at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
    at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
    at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
    at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
    at first_calculator.My.MyApplication.Main(String[] Args) in :line 81

    Inner Exception 1:
    FormatException: Input string was not in a correct format.

    mona kapoor

    (September 17, 2019 - 4:43 am)

    plzzz send link before Tuesday plzzz🙏

    mona kapoor

    (September 17, 2019 - 4:43 am)

    sir / mam your video is very awesome and easily understanding but I want a video on Pythagoras theorem .. sir / mam can u plzz send link ( on visual basic)

    Md. Afsar Ahmed Jakir

    (September 17, 2019 - 4:43 am)

    If you want float number Like(2.555) then you don't put direct text value in variable So you have to coding like this

    Dim Number1 As Single
    Dim Number2 As Single
    Dim Answer As Single

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Number1 = Val(TextBox1.Text)
    Number2 = Val(TextBox.Text)
    Answer = Number1 + Number2

    MessageBox.Show(Answer)
    End Sub

    Just Type Val(TextBox1.Text), It is convert string value to Numaric Value

    Ray-an Fuentes

    (September 17, 2019 - 4:43 am)

    operator '+' is not defined for types 'system.windows.forms.textbox' and system.windows.forms.textbox'

    I can't run. There's an error 🙁

    Andrew Crawford

    (September 17, 2019 - 4:43 am)

    Thanks so much! This helped clarify a lot of things I was having issues with.

    Jonathan Morley

    (September 17, 2019 - 4:43 am)

    Thanks for these vids. I took programming in college but have mostly used java since i've graduated. I've needed to brush up on my vb.net skills since I haven't touched the language since 2009.

    BTW: In this video he mentions changing the Integer to a Single, but you can also change it to a Decimal to actually get it to include the decimal point in the result.

    Ghunghroo Khare

    (September 17, 2019 - 4:43 am)

    plzz explain me the concept of comma in i/p & result
    hw floating pint variable accepts "," and not "." in result msg box

    Roya Bermingham

    (September 17, 2019 - 4:43 am)

    thanku

    Anastasiu David Nicolae

    (September 17, 2019 - 4:43 am)

    Best Visual Basic Calculator Tutorial Ever 🙂 🙂

    Anastasiu David Nicolae

    (September 17, 2019 - 4:43 am)

    Give Code!!!!!

    Extreme MLG Bass Boosts

    (September 17, 2019 - 4:43 am)

    May i ask, Is there a way to an array of text, and seperate them by , I need to get 2.5,5,66, into 2.5 5 66

    ZoyLo

    (September 17, 2019 - 4:43 am)

    ty

    Muhammad Akbar

    (September 17, 2019 - 4:43 am)

    Great

    shesha

    (September 17, 2019 - 4:43 am)

    Shared on Google+

    shesha

    (September 17, 2019 - 4:43 am)

    1

Leave a Reply

Your email address will not be published. Required fields are marked *