text formatting-VBForums
Results 1 to 6 of 6

Thread: text formatting

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2011
    Posts
    16

    text formatting

    basically the software receives a a string var every 30 seconds and places it into a textbox. i then need the text box to format it into a nice clear layout.

    for example the text received may read :
    Return(result="success" dev_id="0" time="2011-07-25 16:43:43" id="1" name="test user" workcode="" status="1" card_src="from_check"

    time="2011-07-25 16:43:45" id="1" name="test user" workcode="" status="1" card_src="from_check"

    i would like the textbox to show it as:
    2011-07-25,16:43:43,1,test user,
    2011-07-25,16:43:45,1,test user,


    Any ideas??

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    8,613

    Re: text formatting

    Off the top of my head.
    Use Split() with double quote as the seperator then grab the wanted elements from the resulting array.
    In this case would be elements 1, 3 and 5

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Dec 2011
    Posts
    16

    Re: text formatting

    Sorry to pester but i have never used split() before, could you give me an example?

    thanks

  4. #4
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    8,613

    Re: text formatting

    If you go to your online help and type in split you will get full info on the function alng with an example.
    A google search for split vb6 should also return a good bit of info.

    Code:
    Private Sub Command1_Click()
    Dim SourceString As String
    Dim MyVar() As String
    
    SourceString = "123,456,789"
    MyVar = Split(SourceString, ",")
    
    End Sub
    In this case the MyVar array will be have 3 elements after the split
    each containing a portion of the original string broken apart at the ,
    Last edited by DataMiser; Feb 22nd, 2012 at 09:28 AM.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Dec 2011
    Posts
    16

    Re: text formatting

    yes i have googled it and have working examples but i cannot get it to split inbetween each "datahere"

  6. #6
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    8,613

    Re: text formatting

    In your case you would need to use the " as the seperator to look for and then look at the odd array numbers to get your values.

    Code:
    MyVar = Split(SourceString, Chr$(34))
    MyVar(1) 3 and 5 would contain the values you mention that your are looking for.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.