[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 200
  • Last Modified:

Getting started with VB.net

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
gmahler5th
Asked:
gmahler5th
1 Solution
 
AmanBrarCommented:
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
 
gmahler5thAuthor Commented:
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
 
AmanBrarCommented:
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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
armoghanCommented:
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
 
planoczCommented:
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
 
gmahler5thAuthor Commented:
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

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now