Solved

Getting started with VB.net

Posted on 2004-10-26
196 Views
Last Modified: 2010-04-24
I am trying to teach myself VB.net, and I thought I would try to create a mortgage calculator.  How would I get started in VB.net using VisualStudio.net to create a mortgate calculator that has the functionality as shown in this image.

http://www.stevetout.com/calculator.gif
0
Question by:gmahler5th
    6 Comments
     
    LVL 2

    Expert Comment

    by:AmanBrar
    Hi,

    First you would need to design the application by placing four textboxes and using Properties window set their Names as:
    txtPrincipal  for Principal Balance
    txtRate        for Interest Rate
    txtYears      for Number of years
    txtAmount   for Payment Amount

    and a Button:
    btnCalculate   for Calculating

    then in the .vb file you need to add the following calculation code:

    Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
            txtAmount.Text = txtPrincipal.Text + (CDbl(txtPrincipal.Text) * CDbl(txtRate.Text) * CDbl(txtYears.Text)) / 100.0
    End Sub

    hope this helps.
    0
     

    Author Comment

    by:gmahler5th
    I've added all of the textboxes and a button.  This is the code in the form on the code view.  I'm not sure I understand what's going on, where to declare my variables.

    Public Class Form1
        Inherits System.Windows.Forms.Form

        Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter

        End Sub
    End Class
    0
     
    LVL 2

    Accepted Solution

    by:
    Hi,
    if you want to use variables, try using this:

    p.s. - if you want the Payment Amount as the total amount of Principal+Interest, then do this:

    Public Class Form1
        Inherits System.Windows.Forms.Form

        'declare your variables here
        Dim dblPrincipal, dblRate, dblYears, dblAmount As Double
       
    Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click

            'assign the values from textboxes to the variables
            dblPrincipal = CDbl(txtPrincipal.Text)
            dblRate = CDbl(txtRate.Text)
            dblYears = CDbl(txtYears.Text)

            'calculate the final amount as principal + interest
            dblAmount = dblPrincipal + (dblPrincipal *  dblRate *  dblYears) / 100.0

            'put the calculated amount in Payment Amount textbox
            txtAmount.Text = dblAmount.ToString
        End Sub
    End Class


    p.s. - If your Payment Amount is just the calculated Interest, then use this:

    Public Class Form1
        Inherits System.Windows.Forms.Form

        'declare your variables here
        Dim dblPrincipal, dblRate, dblYears, dblAmount As Double

    Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click

            'assign the values from textboxes to the variables
            dblPrincipal = CDbl(txtPrincipal.Text)
            dblRate = CDbl(txtRate.Text)
            dblYears = CDbl(txtYears.Text)

            'calculate the amount of interest
            dblAmount = (dblPrincipal * dblRate * dblYears) / 100.0

            'put the calculated amount in Payment Amount textbox
            txtAmount.Text = dblAmount.ToString
        End Sub
    End Class
    0
     
    LVL 18

    Expert Comment

    by:armoghan
    gmahler5th ...
    You didnt paste the whole code
    all your designer code is present in
    "Windows Form Designer generated code" region. See the soruce code and click the + sign to expand and see teh code in it
    0
     
    LVL 27

    Expert Comment

    by:planocz
    Hi,

    Here is where I found good examples for getting started in VB.Net

    .....http://msdn.microsoft.com/vbasic/downloads/samples/101samples.aspx

    Link for ASP programs...

    http://msdn.microsoft.com/asp.net/downloads/kits/default.aspx
    0
     

    Author Comment

    by:gmahler5th
    I just used tried your code and I got some debug errors.  They are visible in this image:

    http://www.stevetout.com/debug-error.jpg

    Any thoughts on how I could fix these errors?
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

    846 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now