I need the folllowing functionality in pure VB code:
Imagine with me if you will that you have two strings:
String One (First Draft):
"I am a silly big green monster"
String Two (Second Draft):
"I am a big blue monster"
Okay, now I need two functions like this:
Private Function GetChrDiff(OldString As String, NewString As String) As String
'Returns a string that is only the difference between
'OldString and NewString
Private Function ApplyChrDiff(OldString As String, DiffString As String) As String
'Takes DiffString and applies it to OldString and
'the result should be the same as the NewString
'that I gave to GetCharDiff
Don't worry about doing a CheckSum, it doesn't matter
if there is an error, I will deal with that later.
Let me put it into a real-world usage example:
Let's say I'm writing a novel, and it is time for me to
hand my publisher the first draft. So I burn the first
draft to a CD, it is 35 MB.
Then, I start on my second draft. I make several changes
to the original, but I decide that I'm still not happy
with the novel. Suddenly I realize that I only have one
floppy disk and no more CD's.
The only way I will have room on the floppy disk to save
my second draft is if I only save the differences between
the two files.
So, using my handy dandy VB program I wrote, I make a text
file that only contains the difference between the first
and second drafts.
Later, when I am on my death bed, I decide that I liked
my second draft better -- but all I have is the original
on CD and the floppy disk with the Difference File on it.
So I open up my handy dandy VB program I wrote and apply
the Difference File on the floppy to the 35 MB file on
the CD and BAM! There is my second draft!
Stupid story, I know. But hopefully it describes what I
need to do.
OH! And remember -- there will be some parts I take out
of the first draft, some parts I replace, and some parts
that I add. So theoretically, the second draft could be
shorter or longer than the original draft.
You can keep the code simple. You don't have to open a file or
save a file in your example. Just deal with the string variables.