Link to home
Start Free TrialLog in
Avatar of Bob Schneider
Bob SchneiderFlag for United States of America

asked on

Remove Quotes From text line in VB6

How can I write the data between the quotes (including the quotes) to a variable sTime, knowing that the string (including the quotes) could be between 11 and 17 characters long:
4,102331,0,"13:24:46.25077",1,4

Open in new window


Thanks!!
ASKER CERTIFIED SOLUTION
Avatar of Norie
Norie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Kimputer
Kimputer

Reference VBScript Regex 5.5 and use this code (VBscript right now, change it to VB):

Dim oRE, oMatches
  Set oRE = New RegExp
  oRE.Global = True
  oRE.IgnoreCase = True
  oRE.Pattern = """[0-9:\.]+"""
  sSearch = "4,102331,0,""13:24:46.25077"",1,4"
  Set oMatches = oRE.Execute(sSearch)

  ' Now process all the matches (if any)
  Dim oMatch
  'wscript.echo "Pattern String: " & Chr(34) & oRE.Pattern & Chr(34)
  'wscript.echo "Search String: " & Chr(34) & sSearch & Chr(34) & VbCrLf
  wscript.echo "Matches: " & CStr(oMatches.Count)
  For Each oMatch In oMatches
    wscript.echo oMatch & vbcrlf & "    " & String(oMatch.FirstIndex, " ") & vbcrlf &  String(oMatch.Length, "^")
  Next
You could use the following code (adjusted to include the quotes):
strData = "4,102331,0," & Chr(34) & "13:24:46.25077" & Chr(34) & ",1,4"
sPos1 = Instr(1, strData, Chr(34), 1)
sPos2 = Instr(sPos1 + 1, strData, Chr(34), 1)
sTime = Mid(strData, sPos1, sPos2 - sPos1 + 1)
Wscript.echo sTime

Open in new window



Avatar of Bob Schneider

ASKER

So I would just use the split function...yes, its always the fourth item.
Thanks!!