Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Replacing strings - data merge
Message
 
 
À
Tous
Information générale
Forum:
Visual Basic
Catégorie:
Autre
Titre:
Replacing strings - data merge
Divers
Thread ID:
00490006
Message ID:
00490006
Vues:
40
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
It's "my" world. You're just living in it.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform