Results 1 to 6 of 6

Thread: problem loading a label on shape control

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Location
    Mumbai
    Posts
    206

    problem loading a label on shape control

    HIIIIIIIII

    following is the code of lading a label on the shape control

    pls check the code & tell me what is the error

    i want the label to place on shape control as the shape & label should move according the x, y given to them
    Code:
    Sub displayonmap1(id As Integer, X As Single, Y As Single)
    If mapshow Then
        On Error Resume Next
        If Not HasIndex(Shape1, id) Then
            Load Shape1(id)
            Shape1(id).Container = Pic
            Shape1(id).Visible = True
            Shape1(id).BorderColor = vbYellow 'QBColor(id)
            Shape1(id).BackColor = vbYellow
            Load Label1(id)
            Label1(id).Container = Shape1(0)' should i put id or its correct in shape index
            Label1(id).Visible = True
            Label1(id).AutoSize = True
            Label1(id).BackColor = vbYellow
            Label1(id).Caption = id
            Label1(id).FontBold = True
            pic_centre
        End If
        Pic.AutoRedraw = True
            With Shape1(id)
                .Move X - Shape1(0).Width / 2, -Y - Shape1(0).Height / 2
                If 0 < 10 Then
                    Label1(id).Move X + 100 - Label1(0).Width / 2, -Y - Label1(0).Height / 2
                ElseIf 0 > 10 Then
                    Label1(id).Move X - 10 - Label1(0).Width / 2, -Y + 50 - Label1(0).Height / 2
             End If
            End With
    End If
    End Sub
    Public Function HasIndex(ControlArray As Object, ByVal Index As Integer) As Boolean
        HasIndex = (VarType(ControlArray(Index)) <> vbObject)
    End Function
    Private Sub Timer1_Timer()
    Set rs = New ADODB.Recordset
    strsql = "select distinct (robot_id) from robotonlineinfo;"
    rs.Open strsql, con, adOpenDynamic, adLockPessimistic
    If rs.RecordCount > 0 Then
        rs.MoveFirst
        While Not rs.EOF
            Set rs1 = New ADODB.Recordset
            strsql = "select top 1 id, x_position,y_position from robotonlineinfo where message_id='3' and id=" & rs(id") & " order by last_updated desc;"
            rs1.Open strsql, con, adOpenKeyset, adLockPessimistic
            displayonmap1 rs1("id"), rs1(1), rs1(2)
            Set rs1 = Nothing
            rs.MoveNext
        Wend
    End If
    Set rs = Nothing
    End Sub
    the above code works if i put 0 in place of id variable of label

    PLSSSSS help if any body can
    Last edited by bhavik; May 18th, 2013 at 03:34 AM. Reason: edited the code
    NAMO NANASHA

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width