Results 1 to 2 of 2

Thread: Problem in VB.NET with code

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2005
    Posts
    20

    Exclamation 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:
    1. Private Sub Calculate(ByVal sender As Object, ByVal e As System.EventArgs) _
    2.     Handles btnArea.Click, btnPerimeter.Click, btnType.Click, btnHeight.Click
    3.  
    4.         Dim sngSideA As Single = Val(Me.txtSideA.Text)
    5.         Dim sngSideB As Single = Val(Me.txtSideB.Text)
    6.         Dim sngSideC As Single = Val(Me.txtSideC.Text)
    7.         Dim UserTriangle As New Triangle(sngSideA, sngSideB, sngSideC)
    8.  
    9.         If UserTriangle.ValidTriangle Then
    10.             Dim btnButtonClicked As Button = sender
    11.             Select Case btnButtonClicked.Tag
    12.                 Case "Area"
    13.                     Me.lblArea.Text = UserTriangle.Area
    14.                 Case "Perimeter"
    15.                     Me.lblPerimeter.Text = UserTriangle.s * 2
    16.                 Case "Type"
    17.                     Me.lblType.Text = UserTriangle.Type
    18.                 Case "Height"
    19.                     Me.lblHeight.Text = UserTriangle.Height
    20.             End Select
    21.         Else
    22.             MessageBox.Show("Measurements typed are not for valid triangle.")
    23.  
    24.             Me.txtSideA.Text = Nothing
    25.             Me.txtSideB.Text = Nothing
    26.             Me.txtSideC.Text = Nothing
    27.         End If
    28.  
    29.     End Sub
    30.  
    31.     Private Sub SideChanged(ByVal sender As Object, ByVal e As System.EventArgs) _
    32.     Handles txtSideA.TextChanged, txtSideB.TextChanged, txtSideC.TextChanged
    33.  
    34.         Me.lblArea.Text = Nothing
    35.         Me.lblPerimeter.Text = Nothing
    36.         Me.lblType.Text = Nothing
    37.     End Sub
    38. End Class

  2. #2
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196

    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
  •  



Click Here to Expand Forum to Full Width