954,160 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

HELP please!!vb.net help.....

hello,i need to make an if statement for a mortgage application in vb.net, basically i have a list box for the DOB called cmbDOB, and a label to show the maximum mortgage. But i dont know how to make the if statement-it has to show the maximum mortage in the label depending on the following:
*Over 50yrs- maximum mortage = 15yrs
*between 40 - 50 = 20yrs
*Between 30 - 40 = 25
*betwen 18 - 30 = 30yrs
*Under 18yrs - NO mortgage!
but my list box has the DOB's as follows - 1940......to....1985. anyone good at writing vb.net language and wanna help me!!!!!please!!!!!!!! :o

shelly121
Newbie Poster
17 posts since Feb 2005
Reputation Points: 10
Solved Threads: 0
 

You may want to use Select Case or
If, ElseIf statements.

Chester

cpopham
Junior Poster in Training
65 posts since Mar 2005
Reputation Points: 10
Solved Threads: 0
 

you can use if statements.

If [your condition here]
Your code here
ElseIf [your condition here]
Your code here
ElseIf [your condition here]
Your code here
Else
Your code Here
End If

for more follow this link

http://vb.net-informations.com/programflow/vb.net_if_else_endif.htm

gever
Newbie Poster
9 posts since Jun 2008
Reputation Points: 10
Solved Threads: 0
 

make it a Select case.. then you can do this issue..

lich
Junior Poster in Training
79 posts since May 2008
Reputation Points: -1
Solved Threads: 4
 

dont go for IF Statements as you having more than three conditions.. go for Select case.. that will be good..

lich
Junior Poster in Training
79 posts since May 2008
Reputation Points: -1
Solved Threads: 4
 

To do this properly, I would focus on allowing the user to select their birthdate with a datetimepicker....or, convert their choices from your listboxes to a date.

You will need to insert error handling and other specifics on your own, as well as adjust the accuracy of the age...but this is very close to what you need.

Public Class Form1
    Dim intage As Integer

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim dtdob As New Date(Me.ListBox1.SelectedItem.ToString, 1, 1)
        ' using this method of calculating the age of the client is inaccurate, but the
        ' function I used offers more granularity for calculating an exact age...you can tweak it.
        intage = Microsoft.VisualBasic.DateAndTime.DateDiff(DateInterval.Year, dtdob, Now)
        populatelistboxitems(intage)
    End Sub

    Private Sub populatelistboxitems(ByVal intage As Integer)
        Me.ListBox2.Items.Clear()
        Select Case intage
            Case Is >= 50
                Me.ListBox2.Items.Add("10 year mortgage")
            Case Is >= 40
                Me.ListBox2.Items.Add("10 year mortgage")
                Me.ListBox2.Items.Add("20 year mortgage")
            Case Is >= 30
                Me.ListBox2.Items.Add("10 year mortgage")
                Me.ListBox2.Items.Add("20 year mortgage")
                Me.ListBox2.Items.Add("25 year mortgage")
            Case Is >= 18
                Me.ListBox2.Items.Add("10 year mortgage")
                Me.ListBox2.Items.Add("20 year mortgage")
                Me.ListBox2.Items.Add("25 year mortgage")
                Me.ListBox2.Items.Add("30 year mortgage")
        End Select
    End Sub
End Class
cutepinkbunnies
Junior Poster
146 posts since Apr 2006
Reputation Points: 15
Solved Threads: 9
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You