Hi
I want to write program ,
part of this program show to me form , this form has multiple picture Box and when I click on picture Box ,the program will show small form that it show information by label
this form takes information from Dinamic array(the user determine the size) and but each element on array in new label .
I need each information on different labels because I want to allow the user to move the label to another bicture box and when the user move the label ,it will be deleted from the original picture box and existed on the form , that will be show when I click second picture box .

how I can use the element of array to name the labels in determined form .. (labels will be created at run time and number of labels depend on the user

frnd its too easy..

On Form_Load I m adding two lables at Runtime & setting their names..On Button4 click. I m getting that two label names..

Imports System.Drawing.Drawing2D

Public Class Form2
   
    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try

            Dim lCount As Integer

            For lCount = 1 To 2
                Dim Lbl As New Label()
                Select Case lCount
                    Case 1
                        Lbl.Name = "Label1"
                        Lbl.Text = "1"
                        Lbl.Location = New Point(39, 79)
                        Me.Controls.Add(Lbl)
                    Case 2
                        Lbl.Name = "Label2"
                        Lbl.Text = "2"
                        Lbl.Location = New Point(139, 79)
                        Me.Controls.Add(Lbl)
                End Select
                Application.DoEvents()
            Next

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Try
            For Each c As Control In Me.Controls
                If InStr(c.Name, "Label", CompareMethod.Text) > 0 Then
                    MsgBox(c.Name.ToString)
                End If
                Application.DoEvents()
            Next
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
End Class

if u get answer ,then marked the thread as solved,cz u r newbie to the site,dats y telling u....hey frm next time plz also put ur code

wat happened,atleast respond soemthing...is this not the soln u r looking for!!!!!!!!1

thnks sonia
this my code
still there are problem
just one label appear at excution
??
I want to show all element of array

Dim server_num As Integer
    Public server_names(9) As String
    Public fragments_allocation(9) As String
    Dim i, j As Integer
    Public array1() As String

   Private Sub server1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles server1.Click
        i = 0
       
        While Not (Label1.Text.Equals(server_names(i)))
            i += 1

        End While
       

        array1 = fragments_allocation(i).Split("-")
        MsgBox(fragments_allocation(i))
        'create new form 
        Dim ser1 As New Form
        Dim d As Integer
        Dim l1 As New Label()
        d = 5
        j = array1.Length
        'put all fragments in the form of selected server(by labels)
        While j <> 0

            j -= 1
            l1.Name = array1(j)

            'I have string that it's name as the value of array(j), I need to put it in text of label , how I can do that ??

            l1.Text = array1(j)
            l1.Location = New Point(5, 5 + d)
            ser1.Controls.Add(l1)

            ser1.Show()

            d += 5
        End While
    End Sub

which array u want to split , fragments_allocation or server_names..& tell the values going into these arrays??????????

I want to split every string in fragments_allcation

the value in servers_names array is the name of server
the value in fragment allocation array is the string contains all fragments name of schema splitted by "-"
and I have for each fragment string declared by same name ,that is contains description for it

Can i give u the eg,Suppose string contains a-b-c-d-e & I then split it with "-" & create the five labels & give them name..Is dat ok..Plz explain in detail wat u want???

yes , that is ok
also I want to add string of name (d) to text of label d ..and string of name(a) to text of label a , ...etc
suppose , a , b , c ,d,e are declared as string
when I split string (a-b-c-d-e)
will appeare form contains five label,that it names a,b,c,d,e
and label.text equal to content of string of that name

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Try
            Dim sArr() As String
            Dim a As String = "a-b-c-d-e"
            Dim lCount As Integer
            Dim bFirstLbl As Boolean = True
            Static lYLocation As Integer

            sArr = Split(a, "-")
            For lCount = 0 To UBound(sArr)
                Dim Lbl As New Label()
                If bFirstLbl = True Then
                    Lbl.Location = New Point(34, 40)
                    lYLocation = 40
                    bFirstLbl = False
                Else
                    Lbl.Location = New Point(34, lYLocation + 40)
                    lYLocation = Lbl.Location.Y
                End If
                Lbl.Name = sArr(lCount)
                Lbl.Text = sArr(lCount)
                Me.Controls.Add(Lbl)
            Next
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

Just copy the code,& paste it,I thk so ur probs is solved now...If yes,dn plz mark this thraed as solved

thanks sonia
that what I want .. except label.text
suppose a="ffffff"
b="ggggggggg" & etc
I want label.text=a:ffffff

in the form will appear as

a:ffffffff
b:ggggggggg
.
.
.
etc

are you understand me ??

I want the content of string ,that element of array refer to it

frnd its too easy,sorry to say dat but u didnt show me any effort.
Anyways i m posting updated code here-

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            Dim sArr() As String
            Dim a As String = "a-b-c-d-e"
            Dim lCount As Integer
            Dim bFirstLbl As Boolean = True
            Static lYLocation As Integer
            Dim sText As String

            sText = ""

            sArr = Split(a, "-")
            For lCount = 0 To UBound(sArr)
                Select Case sArr(lCount)
                    Case "a"
                        sText = "ffffff"
                    Case "b"
                        sText = "gggggg"
                    Case "c"
                        sText = "hhhhhh"
                    Case "d"
                        sText = "iiiiii"
                    Case "e"
                        sText = "JJJJJJ"
                End Select

                Dim Lbl As New Label()
                If bFirstLbl = True Then
                    Lbl.Location = New Point(34, 40)
                    lYLocation = 40
                    bFirstLbl = False
                Else
                    Lbl.Location = New Point(34, lYLocation + 40)
                    lYLocation = Lbl.Location.Y
                End If
                Lbl.Name = sArr(lCount)
                Lbl.Text = sArr(lCount) & ":" & sText
                Me.Controls.Add(Lbl)
            Next
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

    End Sub

Oh, Thanks
but I'm think ,ther are method do that in visual .net
,so I didn't try to write code
thnks sonia

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.