我要用vb做一个界面
 大概是 我用鼠标点击form  就能有一面旗子贴到我点击的那个位置!!??

解决方案 »

  1.   

    Option Explicit
    Dim Index
    Private Sub Form_Load()
    Index = 1
    End Sub
    Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Load P(Index)        '动态加载控件
    P(Index).Left = X    '控件x坐标
    P(Index).Top = Y     '控件y坐标
    P(Index).Visible = True
    Index = Index + 1
    End Subp是pictureBox,将属性中的index设置为0
      

  2.   

    To lz:别人给了代码 还要自己分析一下嘛.
    1楼已经给出了注释了 是要动态加载控件
    自己就应该分析一下是不是应该加上Controls.Add
    Dim Index As Integer
    Dim p() As PictureBox'定义一个Picture数组
    Private Sub Form_Load()
    Index = 1
    End Sub
    Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    ReDim Preserve p(Index)'重定义数组
    Set p(Index) = Form1.Controls.Add("VB.PictureBox", _
                      "TmpPic" & Index, Form1)
     p(Index).Picture = LoadPicture("d:\1.bmp")       '动态加载控件并命名
    p(Index).Left = X    '控件x坐标
    p(Index).Top = Y    '控件y坐标
    p(Index).Visible = True
    Index = Index + 1
    End Sub'p是pictureBox , 将属性中的index设置为0