Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Replacing strings - data merge
Message
General information
Forum:
Visual Basic
Category:
Other
Miscellaneous
Thread ID:
00490006
Message ID:
00490058
Views:
9
Use the Replace() function for a much better approach to what you are
trying to accomplish..

>I'm trying to include a data merge type of functionality in to my current project but need some assistance.
>
>My current code looks like this:
>
>Do
>  lngPos = InStr(1, strMemo, "@PURCHASEORDERID", vbTextCompare)
>  If lngPos = 0 Then
>     Exit Do
>  End If
>  strMemo = Mid(strMemo, 1, lngPos - 1) & _
>     mobjPurchaseOrder.PurchaseOrderID & _
>     Mid(strMemo, lngPos + 16)
>Loop
>
>
>As you can see, it loop thru the string and replaces the string as needed. This works for one but what if I want to check every property in my object for existance of the matching tag string and do a similar replace? Is there a cool way to do this w/o hard-coding the strings to lookup?
>
>Something like this that works:
>
>For Each Property In mobjPurchaseOrder.Properties
>  lngPos = InStr(1, strMemo, "@" & Property.Name, vbTextCompare)
>  If lngPos = 0 Then
>     Exit Do
>  End If
>  intLen = Len(Property.Name)
>  strMemo = Mid(strMemo, 1, lngPos - 1) & _
>     Property.Value & _
>     Mid(strMemo, lngPos + intLen)
>Next
>
Previous
Reply
Map
View

Click here to load this message in the networking platform