+ Reply to Thread
Results 1 to 3 of 3

TextBox and Label Assignment

  1. #1
    Registered User
    Join Date
    10-04-2006
    Posts
    7

    TextBox and Label Assignment

    Hello,
    I am new to VBA and need help in assignment array index to TextBox/Label.
    If I have the following do loop:

    For I =1 to 11;

    TextBox(i) =Sheets("Score Card").Cells(loc(i) + 5,2)
    Label(i) =Sheets("Score Card").Cells(loc(i) + 5,6)
    Next i

    This (i) would not work. What should be the right syntex ?

    Thanks

  2. #2
    Registered User
    Join Date
    09-23-2006
    Posts
    9

    Me too

    hi,
    I am trying to do something similar, except that I have 980 textboxes to populate.

    I am not sure what the syntax is for concatanating (spelling) a key word and a variable.

    (i.e)

    for tb = 1 to 980
    textbox(tb).value = sheet(row1,col1).value
    next tb

    this is where I need to go, but I too am stuck on the textbox issue.

    any help will be greatly appreciated.

    "There are 10 kinds of People in the world, those that understand binary, and those that don't."

  3. #3
    Registered User
    Join Date
    09-11-2006
    Posts
    56

    Finally

    I knew if I was diligent and bugged the right person I could find the solution to this problem.

    Many many thanx to Carim, who was kind enough to provide this solution.

    Private Sub UserForm_Initialize()
    Dim textbox As MsForms.textbox
    Dim i As Integer
    For i = 1 To 6
    Set textbox = UserForm1.Controls("Textbox" & i)
    textbox.Value = Worksheets("Sheet1").Cells(i, 1).Value
    Next i
    End Sub

    this assumes you want it to populate the boxes on the forms opening, you can manipulate the variables to accomodate the number of loops you need.

    Again Thank you Carim, if you need anything done .. dirty deeds done dirt cheap .. jk but I really can't thank you enough.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1