Author Topic: How do I parse a string (vba)  (Read 2298 times)

0 Members and 1 Guest are viewing this topic.

Humbertogo

  • Guest
How do I parse a string (vba)
« on: August 14, 2006, 06:05:26 AM »
I have an string("G4;$$.1000}[312.98{\H0.71x;\G4;$$2.54")

what i intend to do is
read all values that starting with $$
for example
$$.1000
$$2.54
« Last Edit: August 14, 2006, 07:08:26 AM by nivuahc »

Swift

  • Swamp Rat
  • Posts: 596
Re: How do I parse a string (vba)
« Reply #1 on: August 14, 2006, 07:56:39 AM »
What version of VB(A) are you doing this in?

If your working in VB 6 you can you the split function. If your not in version 6 I can dig some stuff up

DaveW

  • Guest
Re: How do I parse a string (vba)
« Reply #2 on: August 14, 2006, 08:23:35 AM »
Like Swift says.

Swift, according to his other posts he's using VB6 and ACAD Mechanical.
« Last Edit: September 12, 2006, 11:45:21 PM by DaveW »

Fatty

  • Guest
Re: How do I parse a string (vba)
« Reply #3 on: August 14, 2006, 09:36:40 AM »
I think easier yet to use something similar on this code,
not sure though

Code: [Select]
Sub ParseBB()
Dim a, b, s, h, t As String
Dim pos As Long
Dim ar() As String
s = "G4;$$.1000}[312.98{\H0.71x;\G4;$$2.54"
a = "$$"
ar = Split(s, a)
s = ar(1)
 
While Left(s, 1) Like "[0-9]" Or Left(s, 1) Like "."
      a = a & Left(s, 1)
      s = Right(s, Len(s) - 1)
Wend

s = ar(2)
b = "$$"
While Left(s, 1) <> ""
b = b & Left(s, 1)
s = Right(s, Len(s) - 1)
Wend
MsgBox "A : " & a & vbNewLine & _
       "B : " & b

End Sub


~'J'~

Humbertogo

  • Guest
Re: How do I parse a string (vba)
« Reply #4 on: August 14, 2006, 09:58:19 AM »
Thanks

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: How do I parse a string (vba)
« Reply #5 on: August 28, 2006, 09:54:09 AM »
At first glance this problem could be easily overcome by using the Regular Expressions found in VBScript.

Please refer to this thread for more.
[ http://www.theswamp.org/index.php?topic=11933.0 ]
TheSwamp.org  (serving the CAD community since 2003)