See Also Example
Applies To
Form, MDI form
Description
Stores any extra data needed for your program. Unlike other properties, the value of the Tag property is not used by Visual Basic; you can use this property to identify objects.
Usage
[form.][control.]Tag[ = expression ]
Remarks
By default, the Tag property is set to an empty string ("").
You can use this property to assign an identification string to an object without affecting any of its other property settings or causing side effects. The Tag property is useful when you need to check the identity of a control or MDI form that is passed as a variable to a procedure.
Tip At the time you create a new instance of a form, assign a unique value to the Tag property.
Data Type
String
Help:
Name Property
Programmer's Guide:
Chapter 3, "Creating and Using Controls"
The example displays a unique icon for each control being dragged. To try this example, paste the code into the Declarations section of a form that contains three picture boxes. Set the DragMode property for Picture1 and Picture2 to 1. Then press F5. Use the mouse to drag Picure1 or Picture2 over Picture3 controls.
Sub Form_Load ()
Picture1.Tag = "Pic1"
Picture2.Tag = "Pic2"
End Sub
Sub Picture3_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
Const ENTER = 0, LEAVE = 1, OVER = 2
If State = ENTER Then
' Select based on Tag. Name is not available at run time.
Select Case Source.Tag
Case "Pic1"
' Load icon for Picture1.
Source.DragIcon = LoadPicture ("icons\arrows\point03.ico")
Case "Pic2"
' Load icon for Picture 2.
Source.DragIcon = LoadPicture ("icons\arrows\point04.ico")
End Select
ElseIf State = LEAVE Then
' When source is not over Picture3.
Source.DragIcon = LoadPicture () 'Unload icon.
End If
End Sub