|
-
Feb 21st, 2012, 09:44 AM
#1
Thread Starter
Junior Member
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??
-
Feb 21st, 2012, 10:43 AM
#2
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
-
Feb 22nd, 2012, 03:19 AM
#3
Thread Starter
Junior Member
Re: text formatting
Sorry to pester but i have never used split() before, could you give me an example?
thanks
-
Feb 22nd, 2012, 09:21 AM
#4
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.
-
Feb 22nd, 2012, 09:29 AM
#5
Thread Starter
Junior Member
Re: text formatting
yes i have googled it and have working examples but i cannot get it to split inbetween each "datahere"
-
Feb 22nd, 2012, 09:47 AM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|