Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21273

problem loading a label on shape control

$
0
0
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

Viewing all articles
Browse latest Browse all 21273

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>