| | |
Please help............
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
this line: If thisyear - cmbDOB > 1955 will NEVER be true (2005 - anything in the 1900's)
what you need to do, is NOT compare by year... compare by the subtracted number. instead of thisyear - cmbdob > 1955, use your table:
*Over 50yrs- maximum mortage = 15yrs
*between 40 - 50 = 20yrs
*Between 30 - 40 = 25
*betwen 18 - 30 = 30yrs
*Under 18yrs - NO mortgage
age = 2005 - 1995 right? Age is 10 now..... so you can say
if age < 18 then.... we know it is, because the kid is 10, but you are comparing to whole dates. So like if 2005 - 1995 (which is ten) > 1955. The comparison, in english, says "if the age is greater than 1955 then." I wouldn't ever want to live to be 1955... I'll be honest. 70 is pushing it for me
Test it by age, not year.
What do you think?
what you need to do, is NOT compare by year... compare by the subtracted number. instead of thisyear - cmbdob > 1955, use your table:
*Over 50yrs- maximum mortage = 15yrs
*between 40 - 50 = 20yrs
*Between 30 - 40 = 25
*betwen 18 - 30 = 30yrs
*Under 18yrs - NO mortgage
age = 2005 - 1995 right? Age is 10 now..... so you can say
if age < 18 then.... we know it is, because the kid is 10, but you are comparing to whole dates. So like if 2005 - 1995 (which is ten) > 1955. The comparison, in english, says "if the age is greater than 1955 then." I wouldn't ever want to live to be 1955... I'll be honest. 70 is pushing it for me
Test it by age, not year.
VB.NET Syntax (Toggle Plain Text)
age = thisyear - val(cmbdob.text) if age > 50 then ' they are over 50 elseif age < 50 and age > 40 then ' between 40 and 50 end if
What do you think?
•
•
Join Date: Feb 2005
Posts: 17
Reputation:
Solved Threads: 0
err ...i fink you knw wot you mean,bt im a bit confused by everthin u jus sed!!sorry! :o does the
go where ive put it...as it underlines "age" everywhere:
thanks
•
•
•
•
age = thisyear - val(cmbdob.text)
•
•
•
•
Private Sub btnMortgage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMortgage.Click
Dim thisyear As Integer = 2005
age = thisyear - Val(cmbDOB.Text)
If age > 50 Then
lblMortgage.Text = ("You maximum morgage years are 15")
ElseIf age <= 50 And age >= 40 Then
' between 40 and 50
lblMortgage.Text = ("You maximum morgage years are 20")
ElseIf age <= 40 And age >= 30 Then
lblMortgage.Text = ("You maximum morgage years are 25")
ElseIf age <= 30 And age >= 18 Then
lblMortgage.Text = ("You maximum morgage years are 30")
ElseIf age < 18 Then
lblMortgage.Text = ("You are to young to get a morgage")
End If
Last edited by shelly121; Feb 24th, 2005 at 5:36 pm. Reason: mistyped
I'm guessing you have an "option explicit" specified somewhere. If that's the case then age is not defined.... you'll need to DIM age as integer, first, or Remove Options Explcit. 
A better explaination of what is going on is this...
You need to know the person's age. That's what's in the table. The person's age. So, you figure out the person's age, by taking today's year, and subtracting that other year, right? Ok, So, We've got the person's age. Now, we need to test the conditions.... is the person older than 50... etc, etc.

A better explaination of what is going on is this...
You need to know the person's age. That's what's in the table. The person's age. So, you figure out the person's age, by taking today's year, and subtracting that other year, right? Ok, So, We've got the person's age. Now, we need to test the conditions.... is the person older than 50... etc, etc.
•
•
Join Date: Feb 2005
Posts: 17
Reputation:
Solved Threads: 0
this is wot iv done from the help uv given me, but now its not displaying anything in the label, please help!!!!??
:•
•
•
•
Private Sub cmbDOB_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbDOB.SelectedIndexChanged
cmbDOB.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Dim i As Integer
For i = 1940 To 1995
cmbDOB.Items.Add(i)
Next i
End Sub
Private Sub btnMortgage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMortgage.Click
Dim thisyear As Integer = 2005
Dim age As Integer
age = thisyear - Val(cmbDOB.Text)
If age > 50 Then
' they are over 50
ElseIf age < 50 And age > 40 Then
' between 40 and 50
lblMortgage.Text = "20 years"
ElseIf age < 30 And age > 40 Then
lblMortgage.Text = "25 years"
ElseIf age < 20 And age > 30 Then
lblMortgage.Text = "30 years"
ElseIf age < 18 Then
lblMortgage.Text = "NO MORTGAGE"
End If
End Sub
Last edited by shelly121; Feb 27th, 2005 at 2:11 pm. Reason: mistype
•
•
Join Date: Feb 2005
Posts: 17
Reputation:
Solved Threads: 0
wel iv gt it partly workn now- its displayying the max mortgage but in the wrong places!! it says "20 years" for all the DOB entered between 1940- 1965?? and "25 years" from 1966 to 1974!!! and so on.... this is the code iv wrote from the help "comotose" gave me! anyone help to y its not quite workin:
•
•
•
•
Private Sub btnMortgage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMortgage.Click
Dim thisyear As Integer = 2005
Dim age As Integer
age = thisyear - Val(cmbDOB.Text)
If age - cmbDOB.Text > 50 Then
' they are over 50
lblMortgage.Text = "15 years"
ElseIf age - cmbDOB.Text < 50 And age > 40 Then
' between 40 and 50
lblMortgage.Text = "20 years"
ElseIf age - cmbDOB.Text < 40 And age > 30 Then
' between 30 and 40
lblMortgage.Text = "25 years"
ElseIf age - cmbDOB.Text < 30 And age > 20 Then
' between 20 and 30
lblMortgage.Text = "30 years"
ElseIf age - cmbDOB.Text < 18 Then
'below 18
lblMortgage.Text = "NO MORTGAGE"
End If
End Sub
End Class
![]() |
Other Threads in the VB.NET Forum
- Previous Thread: Visual basic why does my exe file need dotnetfx?
- Next Thread: Menu bars and tabs in VB.NET
| Thread Tools | Search this Thread |
"crystal .net .net2005 2008 access add advanced application array assignment basic beginner box button buttons center click code combo convert cpu data database datagrid datagridview designer dissertation dissertations dissertationthesis dosconsolevb.net editvb.net employees excel exists firewall forms html image images isnumericfuntioncall listview login map math memory mobile module msaccess mssqlbackend mysql navigate net number opacity open pan pdf picturebox picturebox2 port print printpreview record regex reports" reuse right-to-left save savedialog search serial socket sorting sql sqldatbase sqlserver storedprocedure string temp textbox timer txttoxmlconverter upload useraccounts usercontol usercontrol vb vb.net vb.nettoolboxvisualbasic2008sidebar vba vbnet vista visual visualbasic visualbasic.net visualstudio.net web wpf wrapingcode xml






