Excel VBA 質問スレ Part59at TECH
Excel VBA 質問スレ Part59 - 暇つぶし2ch339:デフォルトの名無しさん
19/02/19 21:21:04.93 eXSGnhOj0.net
>>323
構造体でできなくはない
VBAの構造体、制限多いけどな
Public Type Rect
Top As Integer: Left As Integer: Bottom As Integer: Right As Integer
End Type
Public Function CRect(Top As Integer, Left As Integer, Bottom As Integer, Right As Integer) As Rect
Dim r As Rect
r.Top = Top: r.Left = Left: r.Bottom = Bottom: r.Right = Right
CRect = r
End Function
Public Function PtInRect(Rect As Rect, x As Integer, y As Integer) As Boolean
If Rect.Left < x And Rect.Right > x And Rect.Top < y And Rect.Bottom > y Then
PtInRect = True
End If
End Function
Public Sub test()
Dim r(10) As Rect
r(1) = CRect(10, 10, 100, 100) '...
If PtInRect(r(1), 15, 180) Then
MsgBox "In Rect1"
End If
If PtInRect(CRect(10, 10, 100, 100), 15, 80) Then
MsgBox "In Rect2"
End If
End Sub
改行多すぎらしいので:で詰めて書いてる


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch