Results 1 to 3 of 3

Thread: string label space separate

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2004
    Location
    Bulgaria
    Posts
    12

    string label space separate

    Hello
    vb.net


    i have label1.text = "021 034 045" (space separated)

    i would like to click the button and the string in label1 to be divided on 3 parts and to be sent to the 3 different label.text

    and the result to be as

    label2.text = "021"
    label3.text = "034"
    label4.text = "045"

    can i do this with vb code. any idea?

    thank you
    Krasimir

  2. #2
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    This is one way of acheiving this :
    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, _
    2. ByVal e As System.EventArgs) Handles Button1.Click
    3.     Dim straryLBL1Text() as String
    4.  
    5.     straryLBL1Text = label1.Text.Split(chr(asc(" ")))
    6.    
    7.     label2.text = straryLBL1Text(0)
    8.     label3.text = straryLBL1Text(1)
    9.     label4.text = straryLBL1Text(2)
    10. End Sub

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2004
    Location
    Bulgaria
    Posts
    12
    Thank you Alex

    This is exactly what I need it.

    brgds
    Krasimir

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