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:

Open in new window

Visual Basic Classic

Avatar of undefined
Last Comment
Bob Schneider

8/22/2022 - Mon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

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, "^")

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

Bob Schneider

So I would just use the split function...yes, its always the fourth item.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.