943,502 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 5503
  • VB.NET RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Feb 23rd, 2005
0

Re: Please help............

K.... let me know how it turns out.
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Feb 23rd, 2005
0

Re: Please help............

nope!! i noticed at 1st i hadnt put "val" to all the right places, but its just displaying "no mortgage" to every DOB entered!!! ??
Reputation Points: 10
Solved Threads: 0
Newbie Poster
shelly121 is offline Offline
17 posts
since Feb 2005
Feb 23rd, 2005
0

Re: Please help............

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.

VB.NET Syntax (Toggle Plain Text)
  1. age = thisyear - val(cmbdob.text)
  2. if age > 50 then
  3. ' they are over 50
  4. elseif age < 50 and age > 40 then
  5. ' between 40 and 50
  6. end if

What do you think?
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Feb 24th, 2005
0

Re: Please help............

err ...i fink you knw wot you mean,bt im a bit confused by everthin u jus sed!!sorry! :o does the
Quote ...
age = thisyear - val(cmbdob.text)
go where ive put it...as it underlines "age" everywhere:
Quote ...

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
thanks
Last edited by shelly121; Feb 24th, 2005 at 5:36 pm. Reason: mistyped
Reputation Points: 10
Solved Threads: 0
Newbie Poster
shelly121 is offline Offline
17 posts
since Feb 2005
Feb 24th, 2005
0

Re: Please help............

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.
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Feb 27th, 2005
0

Re: Please help............

this is wot iv done from the help uv given me, but now its not displaying anything in the label, please help!!!!?? :

Quote ...
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
shelly121 is offline Offline
17 posts
since Feb 2005
Feb 27th, 2005
0

Re: Please help............

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:
Quote ...
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
shelly121 is offline Offline
17 posts
since Feb 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Visual basic why does my exe file need dotnetfx?
Next Thread in VB.NET Forum Timeline: Menu bars and tabs in VB.NET





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC