|
-
Mar 3rd, 2005, 09:54 AM
#1
Thread Starter
Junior Member
Problem in VB.NET with code
Im having trouble seeing the answer come up in a triangle project. please help, i already have the classes set up.
VB Code:
Private Sub Calculate(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles btnArea.Click, btnPerimeter.Click, btnType.Click, btnHeight.Click
Dim sngSideA As Single = Val(Me.txtSideA.Text)
Dim sngSideB As Single = Val(Me.txtSideB.Text)
Dim sngSideC As Single = Val(Me.txtSideC.Text)
Dim UserTriangle As New Triangle(sngSideA, sngSideB, sngSideC)
If UserTriangle.ValidTriangle Then
Dim btnButtonClicked As Button = sender
Select Case btnButtonClicked.Tag
Case "Area"
Me.lblArea.Text = UserTriangle.Area
Case "Perimeter"
Me.lblPerimeter.Text = UserTriangle.s * 2
Case "Type"
Me.lblType.Text = UserTriangle.Type
Case "Height"
Me.lblHeight.Text = UserTriangle.Height
End Select
Else
MessageBox.Show("Measurements typed are not for valid triangle.")
Me.txtSideA.Text = Nothing
Me.txtSideB.Text = Nothing
Me.txtSideC.Text = Nothing
End If
End Sub
Private Sub SideChanged(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles txtSideA.TextChanged, txtSideB.TextChanged, txtSideC.TextChanged
Me.lblArea.Text = Nothing
Me.lblPerimeter.Text = Nothing
Me.lblType.Text = Nothing
End Sub
End Class
-
Mar 3rd, 2005, 10:20 AM
#2
Re: Problem in VB.NET with code
I'm not sure what you mean by "having trouble seeing the answer come up"
Is it in relation to this code:
Code:
Select Case btnButtonClicked.Tag
Case "Area"
Me.lblArea.Text = UserTriangle.Area
Case "Perimeter"
Me.lblPerimeter.Text = UserTriangle.s * 2
Case "Type"
Me.lblType.Text = UserTriangle.Type
Case "Height"
Me.lblHeight.Text = UserTriangle.Height
End Select
Is lblArea.Text where one of the answers is supposed to come up and doesn't?
if it is check the value of btnButtonClicked.Tag, does a value exist and is it the right format(uppercase lowercase), also try adding a case else to your select to catch any instances where none of the above cases are true.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|