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

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

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

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

 
0
  #1
Feb 22nd, 2005
Please help!!iv tryed and tryed with this!basically i have a combo box which displays the date-of-births from 1940-1995, and a button to press to display the maximum mortgage in a label. The max mortgage depends on the age of client:
*Over 50yrs- maximum mortage = 15yrs
*between 40 - 50 = 20yrs
*Between 30 - 40 = 25
*betwen 18 - 30 = 30yrs
*Under 18yrs - NO mortgage
and this is wot iv got for my code,but it underlines the "lblMortgage" part, but i dont know how else it can be written??any1 help me??:
Private Sub ComboBox1_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

If thisyear - cmbDOB.Text > 50 Then
lblMortgage = "mortgage years are 15"
ElseIf thisyear - cmbDOB.Text <= 50 And thisyear - cmbDOB.Text >= 40 Then
lblMortgage = ("mortgage years are 25")
ElseIf thisyear - cmbDOB.Text <= 40 And thisyear - cmbDOB.Text >= 30 Then
lblMortgage = ("You maximum morgage years are 25")
ElseIf thisyear - cmbDOB.Text <= 30 And thisyear - cmbDOB.Text >= 18 Then
lblMortgage = ("You maximum morgage years are 30")
ElseIf thisyear - cmbDOB.Text < 18 Then
lblMortgage = ("You are to young to get a morgage")
End If
lblMortgage.Text = thisyear - cmbDOB.Text

End Sub
End Class
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
  #2
Feb 22nd, 2005
I'm guessing lblmortgage is a label (not a textbox) and therefore, would require the use of .caption instead of .text and I'm guessing it's not a variable... so you should also add .caption to the others.... such as
  1. Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbDOB.SelectedIndexChanged
  2. cmbDOB.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
  3. Dim i As Integer
  4. For i = 1940 To 1995
  5. cmbDOB.Items.Add(i)
  6. Next i
  7. End Sub
  8.  
  9. Private Sub btnMortgage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMortgage.Click
  10. Dim thisyear As Integer = 2005
  11.  
  12. If thisyear - cmbDOB.Text > 50 Then
  13. lblMortgage.caption = "mortgage years are 15"
  14. ElseIf thisyear - cmbDOB.Text <= 50 And thisyear - cmbDOB.Text >= 40 Then
  15. lblMortgage.caption = ("mortgage years are 25")
  16. ElseIf thisyear - cmbDOB.Text <= 40 And thisyear - cmbDOB.Text >= 30 Then
  17. lblMortgage.caption = ("You maximum morgage years are 25")
  18. ElseIf thisyear - cmbDOB.Text <= 30 And thisyear - cmbDOB.Text >= 18 Then
  19. lblMortgage.caption = ("You maximum morgage years are 30")
  20. ElseIf thisyear - cmbDOB.Text < 18 Then
  21. lblMortgage.caption = ("You are to young to get a morgage")
  22. End If
  23. lblMortgage.caption = thisyear - cmbDOB.Text
  24.  
  25. End Sub
  26. End Class
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
  #3
Feb 23rd, 2005
hello,thanks 4 replying -

it underlines ".caption" tho?? and when i put the mouse cursor over it, it says
caption is not a member of 'system.windows.forms.label'
???
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
  #4
Feb 23rd, 2005
I was wrong. I'm sorry. I was still operating under the rules of VB6, not .net. The Label is supposed to be .Text, not .Caption.... but instead of using just lblMortgage = try using lblMortgage.text =
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
  #5
Feb 23rd, 2005
hy, thanks, yh i changed it to .text but now its adding up the mortage wrong?? when i enter 1995 it should say "no mortgage" but it says "10", and 1994 displays 11 in the lable, 1993 displays 12 ...and so on???
and iv changed the numbers such as 30 to the actual dates such as 1975, but this still has no effect:
If thisyear - cmbDOB.Text > 1955 Then
lblMortgage.Text = "15 years"
ElseIf thisyear - cmbDOB.Text <= 1955 And thisyear - cmbDOB.Text >= 1965 Then
lblMortgage.Text = "20 years"..................
????
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
  #6
Feb 23rd, 2005
hmn, you could try converting the string to a number first. I'm not sure if .NET does that for you right off the bat or not. You might have to cast it, or you might be able to use val, like: thisyear - val(cmdDob.txt) > 1995 then?
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
  #7
Feb 23rd, 2005
no...... :-| it still doesnt make a difference. thabks for ya help so far tho.

Private Sub ComboBox1_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

If thisyear - Val(cmbDOB.Text) > 1955 Then
lblMortgage.Text = "15 years"
ElseIf thisyear - Val(cmbDOB.Text) <= 1955 And thisyear - Val(cmbDOB.Text) >= 1965 Then
lblMortgage.Text = "20 years"
ElseIf thisyear - Val(cmbDOB.Text) <= 1965 And thisyear - Val(cmbDOB.Text) >= 1975 Then
lblMortgage.Text = "25 years"
ElseIf thisyear - Val(cmbDOB.Text) <= 1975 And thisyear - Val(cmbDOB.Text) >= 1987 Then
lblMortgage.Text = "30 years"
ElseIf thisyear - Val(cmbDOB.Text) < 1987 Then
lblMortgage.Text = "NO MORTGAGE"
End If
lblMortgage.Text = thisyear - Val(cmbDOB.Text)
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
  #8
Feb 23rd, 2005
  1. ElseIf thisyear - Val(cmbDOB.Text) < 1987 Then
  2. lblMortgage.Text = "NO MORTGAGE"
  3. End If
  4.  
  5. ' /* What is this line all about!?!?!? */
  6. lblMortgage.Text = thisyear - Val(cmbDOB.Text)

after you figure out your calculations, using the else if block..... you end your if, right? Immediately after that, you set lblMortgage.text (which, was set in the elseif block) to whatever thisyear = cmbDob.text is.....(which for 1995 is 10, because 2005 -1995 = X?)

Remove that last line:
lblMortgage.Text = thisyear - Val(cmbDOB.Text)

And it should work.
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
  #9
Feb 23rd, 2005
2 be honest, i dnt knw wot that line ws about!!ths is a bit confusin 4 me now! wel...it gets funnier- now its just displaying "no mortgage" for every dob entered!!
Dim thisyear As Integer = 2005

If thisyear - Val(cmbDOB.Text) > 1955 Then
lblMortgage.Text = "15 years"
ElseIf thisyear - Val(cmbDOB.Text) <= 1955 And thisyear - Val(cmbDOB.Text) >= 1965 Then
lblMortgage.Text = "20 years"
ElseIf thisyear - Val(cmbDOB.Text) <= 1965 And thisyear - Val(cmbDOB.Text) >= 1975 Then
lblMortgage.Text = "25 years"
ElseIf thisyear - Val(cmbDOB.Text) <= 1975 And thisyear - Val(cmbDOB.Text) >= 1987 Then
lblMortgage.Text = "30 years"
ElseIf thisyear - Val(cmbDOB.Text) < 1987 Then
lblMortgage.Text = "NO MORTGAGE"
End If
End Sub
Last edited by shelly121; Feb 23rd, 2005 at 12:17 pm. Reason: mistyped
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
  #10
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!!! :o
Last edited by shelly121; Feb 23rd, 2005 at 12:18 pm. Reason: mistyped
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