Results 1 to 3 of 3

Thread: simple question, drawing a blank

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2002
    Posts
    1

    simple question, drawing a blank

    its been along time since ive coded in VB, in fact i was using vb 4 the last time i did anything. now i am using vb.net. question is a have 35 labels on a form. i want to update them all in a do until loop to save time. how do i merge a integer type variable with a control name? the labels are label1, label2, label3, etc.

    ex.
    x = 0
    do until x = 35

    label*x*.text = val(x)
    x = x + 1

    loop

    that is just a rough sample of what i am trying to do. my question is what is the proper syntax for the label*x*.text portion?

    thanks

    -Nick

  2. #2
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    well you could loop through forms.controls and check for the control's name. It wouldnt be very efficient though.... something like this:

    VB Code:
    1. Dim ctrl As Control
    2.        For Each ctrl In Me.Controls
    3.              'Examine all the controls here
    4.        Next

    I would say it's better to do it manually though
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  3. #3
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    err here, this check for every control whose name starts with "Label"

    VB Code:
    1. Dim ctrl As Control
    2.  
    3.         For Each ctrl In Me.Controls
    4.             If Mid$(ctrl.Text, 1, Len("lable")) = "Label" Then
    5.                 ctrl.Text = Mid$(ctrl.Name, Len("label") + 1)
    6.             End If
    7.         Next
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

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