ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] ¸¨ÂI°ÝÃD....(§Ú¥Ø«e±q¥¼¨ì¹Lªº»â°ì)

¦^´_ 6# stillfish00

stillfish00¤j ¦n¯«¡A­ì¨Ó¨º¬OC »y¨¥³á!

³ºµM¥i¥H§ï¼g¦¨VBA~¯u¬O¼F®`­C~

¤]ÁÂÁÂML089ªº°Ñ»P^^~

TOP

¦^´_ 10# ML089
¦Û­q¨ç¼Æ
  1. Function PolyArea(rngPoly As Range)
  2.     Dim i As Long, j As Long
  3.     Dim pix As Double, piy As Double
  4.     Dim pjx As Double, pjy As Double
  5.     Dim arPoly, area As Double
  6.         
  7.     arPoly = rngPoly.Value
  8.     If UBound(arPoly, 2) <> 2 _
  9.         Or arPoly(1, 1) <> arPoly(UBound(arPoly), 1) _
  10.         Or arPoly(1, 2) <> arPoly(UBound(arPoly), 2) Then PolyArea = CVErr(xlErrRef): Exit Function
  11.    
  12.     area = 0
  13.     For i = 1 To UBound(arPoly) - 1
  14.         j = i + 1
  15.         pix = arPoly(i, 1): piy = arPoly(i, 2)
  16.         pjx = arPoly(j, 1): pjy = arPoly(j, 2)
  17.         
  18.         area = area + pix * pjy
  19.         area = area - piy * pjx
  20.     Next
  21.     PolyArea = Abs(area) / 2
  22. End Function
½Æ»s¥N½X

TOP

¦^´_ 12# stillfish00


¦¬¨ì¤F¡A·PÁ¸U¤À
ªì¨B´ú¸Õ OK

§Ú­Ì¤uµ{³]­p­nºâ¤@¨Ç­±¿n¡B§Î¤ß¡BºD©Ê¯xIx¡B Iy¡BIxy µ¥
µ{¦¡³£¬ODOS®É´ÁFORTRAN¼gªº¡A¦bWIN7¡BWIN8¨t²ÎµLªk°õ¦æ(¶V¨Ó¶V¤£¬Û®e)¡C
­è·QÂରEXCEL VBA¨Ó³B²z¡A¬Ý¨Ó§A¤w¸gÀ°§Ú§¹¦¨²Ä¤@¨B¤F¡A·PÁ¡C
{...} ªí¥Ü»Ý­n¥Î CTRL+SHIFT+ENTER ¤TÁä¿é¤J¤½¦¡

TOP

¦^´_ 12# stillfish00
stillfish00¤j ¶W¼F®`¡A¯u¬O¤Ñ¤~­C~
§Ú¦n¦nªº¬ã¨s¤@¤U¡A¯uªºÁÂÁÂ!   ¬Û«H¥H«á§A¦³»Ý­n¡A§O¤H¤]¤@©w·|À°§Aªº^^~

TOP

b]¦^´_ 12# stillfish00

stillfish00 ¤j±z¦n¡A§Ú­è­è¥Î¤F¤@¤U§Aªº¦Û­q¨ç¼Æ(²Ä¤@¦¸¥Î³o­Ó)
¦ý§Ú¤£ª¾¹D«ç»ò¥Î¡A¨º­Ó¨ç¼Æ¨S¦³»¡©ú?! µLªk§P¥X¡A¦pªþ¥ó¡A«ô°U±Ð±Ð§Ú<(_ _)>
ÁÙ¬O¦³¨ä¥L¤H·|¥Î¤F? ML089¤j?  ·P®¦~
P.S.§ÚÁÙµLªk¤U¸üÀÉ®×

¸¨ÂI°ÝÃD_§PÂ_¨Ò¤l_.rar (17.73 KB)

TOP

¦^´_ 15# ui123

µ{¦¡©ñ¦b Module1
A°Ï­±¿n =PolyArea(C4:D8)
{...} ªí¥Ü»Ý­n¥Î CTRL+SHIFT+ENTER ¤TÁä¿é¤J¤½¦¡

TOP

¦^´_ 16# ML089

ML089 ¤j~  O4 Àx¦s©M¤U­±ªº¤½¦¡«ç»ò¶ñ¡AµLªk§P¥XABC°Ï???¡A«ô°UÀ°§Ú¬Ý¤@¤U¡AÁÂÁ§A^^
¤½¦¡¤w©ñ¦b¸Ì­±¤F¡A¦pªþ¥ó(1¤p®É¦^´_3¦¸¥Î¥ú¤F :'( )
¸¨ÂI°ÝÃD_§PÂ_¨Ò¤l_try2.rar (18.36 KB)

TOP

¦^´_ 12# stillfish00
¦¨¥\¤F¡A§P©w¥XABC°Ï¤F ~Ya^^   ÁÂÁÂstillfish00¤j ¤ÎML089¤j

°Ý¤@¤Ustillfish00¤j ¤ÎML089¤j
1)¥]§tÂI¦bABCÃä½t½u¤W«ç»ò¿ì?(±Ä¨ú¦pªG­è¦n¦b­«Å|ªº½u¤W¡A¨ú¸û¤p¨º¤@­Ó(A<B<C)¡A¨Ò¦p¡A­è¦n¦bA°Ï¤ÎB°Ï¥æ±µ½u¤W¡AºâA°Ïªº)
2)³o­Ó¥i¥H¥Î¦b¦hÃä§Î¶Ü? ¦³¨Ç"¤£³W«hªº¦hÃä§Î"©O?
3)ÁÙ¬O¤£À´ A°Ï­±¿n =PolyArea(C4:D8) ¬O­n°µ¤°»ò?
·PÁ¸U¤À<(_ _)>

TOP

¦^´_ 12# stillfish00

Ãö©ó­è­èªº°ÝÃD for stillfish00¤j ¤ÎML089¤j

1)¥]§tÂI¦bABCÃä½t½u¤W«ç»ò¿ì?(±Ä¨ú¦pªG­è¦n¦b­«Å|ªº½u¤W¡A¨ú¸û¤p¨º¤@­Ó(A<B<C)¡A¨Ò¦p¡A­è¦n¦bA°Ï¤ÎB°Ï¥æ±µ½u¤W¡AºâA°Ïªº)
    Ans:­«Å|½u¤W¡A·|§P¬Ò¨S¦AABC°Ï¤W

2)³o­Ó¥i¥H¥Î¦b¦hÃä§Î¶Ü? ¦³¨Ç"¤£³W«hªº¦hÃä§Î"©O?
    Ans:"À³¥Î©Ê«D±`¼s"¡A¥B¥i¥H¹ï¥ô¦ó¦hÃä§ÎµL­­¼W¥[°Ï°ì~¶W¯Å¼F®`

3)ÁÙ¬O¤£À´ A°Ï­±¿n =PolyArea(C4:D8) ¬O­n°µ¤°»ò?
    Ans:ÁÙ¬O¤£À´³o­n°µ¤°»ò @@ ¥i¥H¸Ñ»¡¤@¤U¥\¯à¶Ü? ·P®¦

stillfish00¤j¡A¥i¥H·Q¥X§P­«Å|½u¶Ü?
¯ÊÁ{ªù¤@¸}¤F!
¦pªG­«Å|½u¥i§P¥X¡A´N«D±`"§¹¬ü¤F"¡A¤£µM·|º|§P±¼«Ü¦h½u¤WÂI~
­è­è¨Ï¥Î¤ß±o¡A¶W¹ê¥Î ¦A¦¸ÁÂÁ  stillfish00¤j

TOP

¦^´_ 19# ui123
­×§ï¦p¤U¡A¥i§tÃä¤WªºÂI¡A¦³Àu¥ý¶¶§Ç(¾a«eªºÀu¥ý)
°Ï°ì¤£­­ABC¤T°Ï¥i¦b°Ñ¼Æ¦Û¦æ¼W¥[¡A¦ý­n¨Ì°Ñ¼Æ¶¶§Ç¡C
  1. Function pointInPoly(ptx As Double, pty As Double, arPoly) As Boolean
  2.     Dim i As Long, j As Long
  3.     Dim pix As Double, piy As Double
  4.     Dim pjx As Double, pjy As Double
  5.    
  6.     For i = 1 To UBound(arPoly) - 1
  7.         j = i + 1
  8.         pix = arPoly(i, 1): piy = arPoly(i, 2)
  9.         pjx = arPoly(j, 1): pjy = arPoly(j, 2)
  10.         
  11.         '¦hÃä§ÎÃä¤W
  12.         If (pix - ptx) * (pjy - pty) - (piy - pty) * (pjx - ptx) = 0 And _
  13.             (pix - ptx) * (pjx - ptx) + (piy - pty) * (pjy - pty) <= 0 Then _
  14.         pointInPoly = True: Exit Function
  15.         
  16.         '¦hÃä§Î¤º³¡
  17.         If Not (piy > pty) = (pjy > pty) Then
  18.             If ptx < (pjx - pix) * (pty - piy) / (pjy - piy) + pix Then pointInPoly = Not pointInPoly
  19.         End If
  20.     Next
  21. End Function

  22. Function RegionABC(x As Double, y As Double, ParamArray polyRegion())
  23.     '3rd°Ñ¼Æ¬°A°Ï¡A4th°Ñ¼Æ¬°B°Ï¡C¡C¡C¨Ì¦¹Ãþ±À¡A¶V¾a«eªºÀu¥ý¡C
  24.     Dim i As Long, arPoly
  25.         
  26.     For i = LBound(polyRegion) To UBound(polyRegion)
  27.         arPoly = polyRegion(i).Value
  28.         
  29.         If UBound(arPoly, 2) <> 2 _
  30.             Or arPoly(1, 1) <> arPoly(UBound(arPoly), 1) _
  31.             Or arPoly(1, 2) <> arPoly(UBound(arPoly), 2) Then RegionABC = CVErr(xlErrRef): Exit Function
  32.         
  33.         If pointInPoly(x, y, arPoly) Then
  34.             RegionABC = Chr(65 + i - LBound(polyRegion))    '¨Ì¶¶¦ìÅã¥ÜA¡AB¡AC¡AD
  35.             Exit Function
  36.         End If
  37.     Next i
  38.     RegionABC = "¤£¦b½d³ò¤º"
  39. End Function
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : ¡i®É¤é²öªÅ¹L¡j¤@­Ó¤H¦b¥@¶¡°µ¤F¦h¤Ö¨Æ¡A´Nµ¥©ó¹Ø©R¦³¦hªø¡C¦]¦¹¥²¶·»P®É¶¡Ävª§¡A¤Á²ö¨Ï®É¤éªÅ¹L¡C
ªð¦^¦Cªí ¤W¤@¥DÃD