Results 1 to 5 of 5

Thread: Textbox

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2006
    Posts
    17

    Textbox

    Hi Guy

    i got a textbox contain the some value with comma(1,25,85,47,32,48)

    And i want to take that value and place in their correct textbox ex

    1 will go into txtbox1
    25 will go into txtbox25
    32 will go into txtbox32
    47 will go into txtbox47
    48 will go into txtbox48

    and so one

    How can i make a loop that does that?

    Thank You

  2. #2
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: Textbox

    VB Code:
    1. Dim tmp() As String
    2.     tmp=Split([B]yourOriginalTextBox[/B].Text,",")
    3.         txtbox1.Text=tmp(0)
    4.         txtbox25.Text=tmp(1)
    5.         txtbox32.Text=tmp(2)
    6.         txtbox47.Text=tmp(3)
    7.         txtbox48.Text=tmp(4)
    Rename yourOriginalTextBox with yours

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Textbox

    you have 99 textboxes, to cover all values?
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  4. #4
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Textbox

    or in a loop:
    VB Code:
    1. Dim sParts() As String, N As Long
    2. sParts = Split(yourOriginalTextBox.Text, ",")
    3.  
    4. For N = 0 To UBound(sParts)
    5.     Me.Controls("Text" & sParts(N)).Text = sParts(N)
    6. Next N
    all seems a bit pointless though - there's probably much better ways of achieving whatever it is you're trying to do.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    May 2006
    Posts
    17

    Re: Textbox

    Hi guy look good but one problem is there a number in the text --99 (1,25,85,47,32,48,99)

    and there not a textbox to put 99 i need it to tell (msgbox) that 99 is wrong.

    what i am trying to do is the the (1,25,85,47,32,48) and make sure it contain all the require number and do not consit of anyother value or any short value.

    Thank You so far on what u did for me.So can you please check that out for me.

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