| | |
Please help............
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Feb 2005
Posts: 17
Reputation:
Solved Threads: 0
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: 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??:
•
•
•
•
*Over 50yrs- maximum mortage = 15yrs
*between 40 - 50 = 20yrs
*Between 30 - 40 = 25
*betwen 18 - 30 = 30yrs
*Under 18yrs - NO mortgage
•
•
•
•
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
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)
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.caption = "mortgage years are 15" ElseIf thisyear - cmbDOB.Text <= 50 And thisyear - cmbDOB.Text >= 40 Then lblMortgage.caption = ("mortgage years are 25") ElseIf thisyear - cmbDOB.Text <= 40 And thisyear - cmbDOB.Text >= 30 Then lblMortgage.caption = ("You maximum morgage years are 25") ElseIf thisyear - cmbDOB.Text <= 30 And thisyear - cmbDOB.Text >= 18 Then lblMortgage.caption = ("You maximum morgage years are 30") ElseIf thisyear - cmbDOB.Text < 18 Then lblMortgage.caption = ("You are to young to get a morgage") End If lblMortgage.caption = thisyear - cmbDOB.Text End Sub End Class
•
•
Join Date: Feb 2005
Posts: 17
Reputation:
Solved Threads: 0
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:
????
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"..................
•
•
Join Date: Feb 2005
Posts: 17
Reputation:
Solved Threads: 0
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)
VB.NET Syntax (Toggle Plain Text)
ElseIf thisyear - Val(cmbDOB.Text) < 1987 Then lblMortgage.Text = "NO MORTGAGE" End If ' /* What is this line all about!?!?!? */ 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.
•
•
Join Date: Feb 2005
Posts: 17
Reputation:
Solved Threads: 0
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
![]() |
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 |
.net .net2008 2005 2008 access account arithmetic array basic bing browser button buttons center check code crystalreport cuesent data database datagrid datagridview date datetimepicker dissertation dissertations dissertationtopic dropdownlist eclipse excel fade file-dialog filter ftp generatetags google gridview hardcopy images input insert intel internet listview mobile monitor ms net networking objects output panel passingparameters pdf picturebox picturebox1 port position print printing problem project read remove save searchbox searchvb.net select serial server settings shutdown soap survey table tcp temperature text textbox timer timespan toolbox transparency trim update user vb vb.net vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio2008 web winforms wpf year






