We help IT Professionals succeed at work.

Remove Quotes From text line in VB6

Bob Schneider
on
57 Views
Last Modified: 2020-05-08
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!!
Comment
Watch Question

Analyst Assistant
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
KimputerIT Manager
CERTIFIED EXPERT

Commented:
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
CERTIFIED EXPERT

Commented:
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



Bob SchneiderCo-Owner

Author

Commented:
So I would just use the split function...yes, its always the fourth item.
Thanks!!
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.