|
-
May 18th, 2013, 03:32 AM
#1
Thread Starter
Addicted Member
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
-
May 18th, 2013, 04:30 AM
#2
Re: problem loading a label on shape control
As far as I understand, a Shape cannot be a Container for any other controls. If you remove the 'On Error Resume Next' statement in your code I suspect you'll see an 'Object does not support this Property or Method' error.
-
May 18th, 2013, 05:10 AM
#3
Thread Starter
Addicted Member
Re: problem loading a label on shape control
ya tats true i m getting invalid picture error
So what should i do
should i take it as picture box container
but this is also not loading the label with the caption
or any other solution
i just want to display the text to identify the shape which is displayed
So any help
Last edited by bhavik; May 18th, 2013 at 05:23 AM.
NAMO NANASHA
-
May 18th, 2013, 07:43 PM
#4
Re: problem loading a label on shape control
I see lots of errors in your code.
Code:
Sub displayonmap1(id As Integer, X As Single, Y As Single)
If mapshow Then
If Not HasIndex(Shape1, id) Then
Load Shape1(id)
With Shape1(id)
'Set .Container = Pic '*** Not sure if this is need ***
.Visible = True
.BorderColor = vbYellow 'QBColor(id)
.BackColor = vbYellow
.Width = 500 'You need to identify a width/height to see it (even if Visible = True)!! Because you loaded a new control.
.Height = 500 'You need to identify a width/height to see it (even if Visible = True)!! Because you loaded a new control.
End With
Load Label1(id)
With Label1(id)
'Set .Container = Shape1(0) '*** Not sure if this is need ***
.Visible = True
.AutoSize = True
.BackColor = vbYellow
.Caption = id
.FontBold = True
.Width = 500 'You need to identify a width/height to see it (even if Visible = True)!! Because you loaded a new control.
.Height = 500 'You need to identify a width/height to see it (even if Visible = True)!! Because you loaded a new control.
End With
pic_centre
End If
Pic.AutoRedraw = True
With Shape1(id)
.Move X - Shape1(0).Width / 2, -Y - Shape1(0).Height / 2
End With
With Label1(id)
If 0 < 10 Then
.Move X + 100 - Label1(0).Width / 2, -Y - Label1(0).Height / 2
ElseIf 0 > 10 Then
.Move X - 10 - Label1(0).Width / 2, -Y + 50 - Label1(0).Height / 2
End If
End With
End If
End Sub
This is not tested, and I do not know much about DataBase.
I'm not sure how your code is calculating (looks like a weird formula!) the position of the shapes.
-
May 20th, 2013, 03:02 AM
#5
Thread Starter
Addicted Member
Re: problem loading a label on shape control
Max187Boucher
AS of container is require since the shape is not since inside picture box if not used
and width & height case i dont see the problem with it
but instead of giving some value can we give same width & height of control shape1(0) and label1(0)
i will check the rest part of code is it working or not
tks for reply
-
May 20th, 2013, 07:12 AM
#6
Thread Starter
Addicted Member
Re: problem loading a label on shape control
Max187Boucher
the above code change is not display the caption while shape is moving the label should display as it is not doing so
not must effect of the above code
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|