|
-
Mar 8th, 2010, 11:00 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Help with delimiters in a string
If I have the following variables and string:
Dim line, type, id, filename As String
line= "p,12345,nothing.jpg"
How can I do the following?
type=p
id=12345
filename=nothing.jpg
So how can I split this string up into those smaller strings?
Thanks!
-
Mar 8th, 2010, 11:08 AM
#2
Re: Help with delimiters in a string
You can use the Split function. Something like this:
Code:
Dim line, type, id, filename As String
Dim values() As String
line = "p,12345,nothing.jpg"
values = line.Split(","c)
If values.Length = 3 Then
type = values(0)
id = values(1)
filename = values(2)
End If
-
Mar 8th, 2010, 11:20 AM
#3
Thread Starter
Addicted Member
Re: Help with delimiters in a string
-
Mar 8th, 2010, 11:21 AM
#4
New Member
Re: [RESOLVED] Help with delimiters in a string
Code:
Dim sData As String = "p,12345,nothing.jpg"
Dim sInfo() As String = Split(sData$, ",")
Dim sType, sID, sFileName As String
sType$ = sInfo$(0)
sID$ = sInfo$(1)
sFileName$ = sInfo$(2)
MsgBox("Type: " & sType$ & vbCrLf & _
"ID: " & sID$ & vbCrLf & _
"Filename: " & sFileName$)
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
|