Public Sub DispBldgSize()
Dim myIndex As Integer = BindingContext (myDv, "customers").Position
Dim myHeight As Double
Dim myDvChd As DataView
Dim myDvRow As DataRowView
Dim myWidth, myLength, myDoor As Integer
Dim myChild As Object = myDvChd.Item(myIndex).CreateChildView("custquotes")
For Each myDvRow In myChild
If IsDBNull(myDvRow("bldg_width")) Then
myWidth = 0
Else
myWidth = myDvRow("bldg_width")
End If
If IsDBNull(myDvRow("bldg_length")) Then
myLength = 0
Else
myLength = myDvRow("bldg_length")
End If
If IsDBNull(myDvRow("bldg_height")) Then
myHeight = 0
Else
myHeight = myDvRow("bldg_height")
End If
If IsDBNull(myDvRow("door_height")) Then
myDoor = 0
Else
myDoor = myDvRow("door_height")
End If
Next
myDvRow("bldg_size") = CalcBldgSize(myWidth, myLength, myHeight, myDoor)
End Sub
Public Function CalcBldgSize(ByVal bWidth As Integer, ByVal _
bLength As Integer, ByVal bHeight As Double, ByVal dHeight As Integer) As String
Dim myHeightI, myHeightF As Integer
Dim mySize As String, myFraction As Double
If bWidth = 0 Or bLength = 0 Or bHeight = 0 Then
CalcBldgSize = "N/A"
Else
bHeight += (dHeight / 12)
myHeightF = Conversion.Fix(bHeight)
myFraction = bHeight - (Conversion.Fix(bHeight))
myHeightI = Math.Round(myFraction * 12)
mySize = bWidth & "' W x " & bLength & "' L x "
If myHeightI = 0 Then
mySize &= myHeightF & "' H"
Else
mySize &= myHeightF & "' " & myHeightI & ControlChars.Quote & " H"
End If
CalcBldgSize = mySize
End If
End Function