際際滷

際際滷Share a Scribd company logo
Function TraBang2Chieu(ByVal Hang, ByVal Cot, VungChon As Range)
'PMXD'
Dim i As Long, j As Long
Dim TangAnPha
Dim NoiSuy1 As Double, NoiSuy2 As Double
For i = 1 To UBound(VungChon.Value, 2) ' Theo phuong ngang
If Hang = VungChon(1, i) Then
For j = 1 To UBound(VungChon.Value, 1) - 1
If (Cot - VungChon(j, 1)) * (Cot - VungChon(j + 1, 1)) <= 0 Then
TangAnPha = (VungChon(j + 1, i) - VungChon(j, i)) / (VungChon(j + 1,
1) - VungChon(j, 1))
TraBang2Chieu = VungChon(j, i) + (Cot - VungChon(j, 1)) * TangAnPha
GoTo Thoat:
End If
Next j
ElseIf (Hang - VungChon(1, i)) * (Hang - VungChon(1, i + 1)) < 0 Then
For j = 1 To UBound(VungChon.Value, 1) - 1
If (Cot - VungChon(j, 1)) * (Cot - VungChon(j + 1, 1)) < 0 Then
TangAnPha = (VungChon(j, i + 1) - VungChon(j, i)) / (VungChon(1, i +
1) - VungChon(1, i))
NoiSuy1 = VungChon(j, i) + (Hang - VungChon(1, i)) * TangAnPha
TangAnPha = (VungChon(j + 1, i + 1) - VungChon(j + 1, i)) /
(VungChon(1, i + 1) - VungChon(1, i))
NoiSuy2 = VungChon(j + 1, i) + (Hang - VungChon(1, i)) * TangAnPha
TangAnPha = (NoiSuy2 - NoiSuy1) / (VungChon(j + 1, 1) - VungChon(j,
1))
TraBang2Chieu = NoiSuy1 + (Cot - VungChon(j, 1)) * TangAnPha
GoTo Thoat:
End If
Next j
End If
Next i
Thoat:
'TraBang = UBound(VungChon.Value, 2)
End Function

More Related Content

Ns 2 chieu

  • 1. Function TraBang2Chieu(ByVal Hang, ByVal Cot, VungChon As Range) 'PMXD' Dim i As Long, j As Long Dim TangAnPha Dim NoiSuy1 As Double, NoiSuy2 As Double For i = 1 To UBound(VungChon.Value, 2) ' Theo phuong ngang If Hang = VungChon(1, i) Then For j = 1 To UBound(VungChon.Value, 1) - 1 If (Cot - VungChon(j, 1)) * (Cot - VungChon(j + 1, 1)) <= 0 Then TangAnPha = (VungChon(j + 1, i) - VungChon(j, i)) / (VungChon(j + 1, 1) - VungChon(j, 1)) TraBang2Chieu = VungChon(j, i) + (Cot - VungChon(j, 1)) * TangAnPha GoTo Thoat: End If Next j ElseIf (Hang - VungChon(1, i)) * (Hang - VungChon(1, i + 1)) < 0 Then For j = 1 To UBound(VungChon.Value, 1) - 1 If (Cot - VungChon(j, 1)) * (Cot - VungChon(j + 1, 1)) < 0 Then TangAnPha = (VungChon(j, i + 1) - VungChon(j, i)) / (VungChon(1, i + 1) - VungChon(1, i)) NoiSuy1 = VungChon(j, i) + (Hang - VungChon(1, i)) * TangAnPha TangAnPha = (VungChon(j + 1, i + 1) - VungChon(j + 1, i)) / (VungChon(1, i + 1) - VungChon(1, i)) NoiSuy2 = VungChon(j + 1, i) + (Hang - VungChon(1, i)) * TangAnPha TangAnPha = (NoiSuy2 - NoiSuy1) / (VungChon(j + 1, 1) - VungChon(j, 1)) TraBang2Chieu = NoiSuy1 + (Cot - VungChon(j, 1)) * TangAnPha GoTo Thoat: End If Next j End If Next i Thoat: 'TraBang = UBound(VungChon.Value, 2) End Function