Please help............

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

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

 
0
  #11
Feb 23rd, 2005
K.... let me know how it turns out.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 17
Reputation: shelly121 is an unknown quantity at this point 
Solved Threads: 0
shelly121 shelly121 is offline Offline
Newbie Poster

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

 
0
  #12
Feb 23rd, 2005
nope!! i noticed at 1st i hadnt put "val" to all the right places, but its just displaying "no mortgage" to every DOB entered!!! ??
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

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

 
0
  #13
Feb 23rd, 2005
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.

  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?
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 17
Reputation: shelly121 is an unknown quantity at this point 
Solved Threads: 0
shelly121 shelly121 is offline Offline
Newbie Poster

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

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

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
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

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

 
0
  #15
Feb 24th, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 17
Reputation: shelly121 is an unknown quantity at this point 
Solved Threads: 0
shelly121 shelly121 is offline Offline
Newbie Poster

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

 
0
  #16
Feb 27th, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 17
Reputation: shelly121 is an unknown quantity at this point 
Solved Threads: 0
shelly121 shelly121 is offline Offline
Newbie Poster

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

 
0
  #17
Feb 27th, 2005
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC