943,495 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 5503
  • VB.NET RSS
You are currently viewing page 1 of this multi-page discussion thread
Feb 22nd, 2005
0

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

Expand Post »
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:
Quote ...
*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??:
Quote ...
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
shelly121 is offline Offline
17 posts
since Feb 2005
Feb 22nd, 2005
0

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

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
VB.NET Syntax (Toggle Plain Text)
  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
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............

hello,thanks 4 replying -

it underlines ".caption" tho?? and when i put the mouse cursor over it, it says
Quote ...
caption is not a member of 'system.windows.forms.label'
???
Reputation Points: 10
Solved Threads: 0
Newbie Poster
shelly121 is offline Offline
17 posts
since Feb 2005
Feb 23rd, 2005
0

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

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 =
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............

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

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

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?
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............

no...... :-| it still doesnt make a difference. thabks for ya help so far tho.

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

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

VB.NET Syntax (Toggle Plain Text)
  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.
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............

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!!
Quote ...
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
shelly121 is offline Offline
17 posts
since Feb 2005
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!!! :o
Last edited by shelly121; Feb 23rd, 2005 at 12:18 pm. Reason: mistyped
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