|
-
Aug 6th, 2001, 02:16 PM
#1
Thread Starter
Lively Member
Inserting Text in a Memo Field...
OK, so I'm trying to extract code from a few different projects I've done to make a cute little personal library.
(I'm also working on a project at work documenting rules created in our app, so this will come in handy)
Basically, what I've got so far is a variable that has an entire VB procedure in it. I want to insert that variable into a memo field in Access. Unfortunately, because it's code, there are loads of quotes and spaces and all sorts of things that make it hard to interpert as just one string.
Is there anyway to loop through a paragraph (or a procedure in this case) write each line into a variable and then update a memo field with that variable with out doing a search through the whole string and doubling up the quotes?
Any help is appreciated.
-
Aug 6th, 2001, 03:25 PM
#2
If you just want to double up the quotes, why not use the Replace() function?, i.e.
VB Code:
sFormatted = Replace(sRawCode, "'", "''")
-
Aug 7th, 2001, 09:24 AM
#3
Thread Starter
Lively Member
That won't work unfortunately.
If I search for each " and replace it with "" then I'll never get past the first ". I end up with """"""""""""""""""""""""""""""""""""""" for eternity.
Any other ideas?
The worst part is I really need this done in about 30 minutes.
Possible, right? :-)
-
Aug 7th, 2001, 01:14 PM
#4
If you use the actual Replace() function in VB you don't have to do any kind of manual search and replace, it will convert all instances of the specified character/string into the replacement character/string.
The Replace() function is only available in VB6, I believe.
-
Aug 7th, 2001, 01:20 PM
#5
Thread Starter
Lively Member
I know, but I'm in VB 5 right now. And wouldn't it still replace every " with a "" making it endless?
-
Aug 7th, 2001, 02:11 PM
#6
No, it wouldn't be endless as it would do something like this:
VB Code:
Public Function ReplaceEx(ByVal sExpression As String, ByVal sFind As String, ByVal sReplace As String) As String
Dim lChar As Long
Dim sNew As String
Do
lChar = InStr(sExpression, sFind)
If lChar Then
sNew = sNew & Left(sExpression, lChar - 1) & sReplace
sExpression = Mid(sExpression, lChar + Len(sFind))
End If
Loop While lChar
ReplaceEx = sNew & sExpression
End Function
-
Aug 8th, 2001, 06:38 AM
#7
Thread Starter
Lively Member
Thank you so much! It works beautifully!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|