Results 1 to 5 of 5

Thread: for next and textboxes

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2007
    Posts
    18

    for next and textboxes

    Hi people,

    I'm a beginner at this so please bear with me...
    I'm trying to write a program and I need to get a for next statement that works with textboxes.
    I know from vba that the me.controls statement will do just that, but apparently If i try this in vb.net 2005 this won't work: I get a "property item is read only" error.

    I tried this code:
    Code:
    dim i as integer
    for i = 1 to 10
      me.controls("textbox" & i ) = i
    next i
    what am i doing wrong and how cn i make it right

  2. #2
    Frenzied Member stimbo's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    1,739

    Re: for next and textboxes

    what exactly are you trying to do?
    Stim

    Free VB.NET Book Chapter
    Visual Basic 2005 Cookbook Sample Chapter

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: for next and textboxes

    Welcome to the forums.

    What is it that you are trying to do? Just loop through your textboxs?

  4. #4
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: for next and textboxes

    Me.Controls(index/name) returns a control, youre trying to put an Integer value in its place. I assume you want to set it to the textboxes textvalue:

    vb.net Code:
    1. dim i as integer
    2. for i = 1 to 10
    3.   me.controls("textbox" & i ).Text = i.ToString()
    4. next i
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Oct 2007
    Posts
    18

    Re: for next and textboxes

    sorry for my late reply guys, but i haven't had time to continue working on the project.

    thanks for replying, i will try Atheist's method, it seems to be doing what i'm trying to accomplish

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