数据库如下:
ID     name    N11           N12     N21     N22    intr
自动  标题    第一点X坐标   一Y     二X     二Y     内容这表示以(N11,N12),(N21,N22)两点为对角线的矩形有内容(intr)数据库中有很多这样的记录,现在给出某个坐标(X,Y) 如何判断该坐标是否在
(N11,N12),(N21,N22)内 如果在显示出intr的内容

解决方案 »

  1.   

    rs.open select * from [table] where x>N11 and x<N21 and y>N12 and y<N22
    text1.text=rs!instr
      

  2.   

    先转换成标准一些的矩形
    min(n11,n21),min(n12,n22)
    max(n11,n21),max(n12,n22)
    然后判断点的位置
    min(n11,n21) < x < max(n11,n21) and min(n12,n22) < y < max(n12,n22)sql语句如下:
    select * from yourtable where iif(n11>n21, n21,n11) < " & x & " and iif(n11<n21, n21,n11) > " & x & " and iif(n12>n22, n22,n12) < " & y & " and iif(n12<n22, n22,n12) > " & y没空检测了,你自己检测把,如果错了的话自己改改就行了。
      

  3.   

    Option ExplicitPublic Conn As New ADODB.Connection
    Public StrSQL As StringPrivate Sub Command1_Click()
    Dim mRst As New ADODB.Recordset
    Dim I As Integer
    Dim X As Double
    Dim Y As Double
        X = TextBox1.Text
        Y = TextBox2.Text
        mRst.CursorLocation = adUseClient
        StrSQL = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.mdb" & ";Persist Security Info=False"
        Conn.Open StrSQL
        mRst.Open "Select intr From 矩阵内容表 Where N11 <= " & CStr(X) & " And N21 >= " & CStr(X) & " And N12 <= " & CStr(Y) & " And N22 >= " & CStr(Y), StrSQL, adOpenKeyset, adLockOptimistic, adCmdText
        For I = 1 To mRst.RecordCount
            Debug.Print mRst("intr")
            mRst.MoveNext
        Next
    End Sub