HELP! (or....What the hell is wrong with this code?)

  • Thread starter Thread starter Sam
  • Start date Start date
S

Sam

I'm writing an address processing app in C#, using an ActiveX
component (Addr) written in VB6, for which I have the source code. The
main function is FixAddress, which takes a string representing the
address to process (as tab separated fields) and returns a validated
and "standardized" address as a (tab separated) string of address
fields. Here is the code that's driving me nuts (minus a lot of
parsing/error checking stuff):

//******** begin ***********

string inputAddr;
string outputAddr;
string allAddr; // all addresses, separated by "\n"

//Block 1
inputAddr = "415 N Western\t#4\tChicago\tIL\t60625";
outputAddr = Addr.FixAddress(inputAddr);
allAddr = outputAddr + "\n";

//Block 2
inputAddr = "235 East Fullerton\tApt 111\tMiami\tFL\t33174";
outputAddr = Addr.FixAddress(inputAddr);
allAddr = allAddr + outputAddr + "\n";

//********* end ************

Looks pretty simple, but when I run it, allAddr only has the value
assigned in Block 1, minus the newline. When I step through the code,
I can see the variable outputAddr in Block 2 set to the right value,
but, again, the concatenation does NOT work, allAddr is unchanged. I
have even tried something like allAddr = allAddr + "XXX"; but even in
that case allAddr remains unchanged.
WHAT IS GOING ON? Is there something about strings returned from an
unmanaged app that makes them behave like this?

help...

Sam
 
Sam said:
Nevermind, I found the problem: it seems like the string returned from
the ActiveX component is null terminated.

Note that that will stop the debugger working properly (in VS.NET 2002,
anyway) but shouldn't stop the concatenation from happening itself -
it's just the debugger doesn't show values after a null. The values are
still there though.
 
Back
Top