' ptinrect.vb Imports System Imports System.Runtime.InteropServices _ Structure POINT Public x As Integer Public y As Integer End Structure _ Structure RECT Public left As Integer Public top As Integer Public right As Integer Public bottom As Integer End Structure Class PointInRect _ Private Shared Function PtInRect _ (ByRef r As Rect, ByVal p As Point) As Boolean End Function Private Shared Function ReadValue(ByVal prompt As String) As Integer Console.Write(prompt + " = ") Return Int32.Parse(Console.ReadLine()) End Function Public Shared Sub Main() Dim r As RECT, p As POINT p.x = ReadValue("点のx座標") p.y = ReadValue("点のy座標") r.left = ReadValue("長方形の左上隅のx座標") r.top = ReadValue("長方形の左上隅のy座標") r.right = ReadValue("長方形の右下隅のx座標") r.bottom = ReadValue("長方形の右下隅のy座標") If PtInRect(r, p) Then Console.WriteLine("内側") Else Console.WriteLine("外側") End If End Sub End Class ' コンパイル方法: vbc ptinrect.vb