Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Cross post

Author  Topic 

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2005-07-26 : 12:15:04
I have a piece of code that I thought was dead simple but it doesn't work and I can't see why. Just to make it even more frustrating it worked fine in my initial testing.

Here is what happened. I created a web form with a text box and a button. If I put a post code into the text box e.g. "la2 1fy" then press the button it converts the post code to the format "la2+1fy" which is what I want.

I then altered the button so that if I put a number in the text box, it would call my stored procedure which returns the post code (as above) this part works fine. I then have the line

sPostCode.Replace(" ", "+")


which worked before but is no longer working. i.e. it ignores the space in the post code.

If I do a

stemp = Asc(Mid(sPostCode, 4, 1))


I get the value I expect (32).

Anyone have any clues what's going on, or more importantly, why the replace has stopped working. I don't doubt that I have missed something silly but I just can't see it

btw - forgot to mention am using VB.NET

thanks

steve






Alright Brain, you don't like me, and I don't like you. But lets just do this, and I can get back to killing you with beer.

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-07-26 : 12:20:30
shouldn't it be
sPostCode = sPostCode.Replace(" ", "+")

Go with the flow & have fun! Else fight the flow
Go to Top of Page

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2005-07-26 : 17:36:40
Hi spirit, that's a good question _ I honestly don't know the answer but I do know that it worked as it is the first time I tried it so I assumed that was the syntax (i'm more familiar with older versions of VB)

I'll have a go with that but if it works I think I will be even more confused

cheers

steve

Alright Brain, you don't like me, and I don't like you. But lets just do this, and I can get back to killing you with beer.
Go to Top of Page

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2005-07-27 : 03:59:39
Spirit - your suggestion worked. Many thanks

I hate Visual Studio!


steve

Alright Brain, you don't like me, and I don't like you. But lets just do this, and I can get back to killing you with beer.
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-07-27 : 05:45:45
i love it

sPostCode = sPostCode.Replace(" ", "+")
is more logical to me than
sPostCode.Replace(" ", "+")

because you manipulate the string and return the result and not just assign the result to the original variable...
now that could bring chaos


Go with the flow & have fun! Else fight the flow
Go to Top of Page

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2005-07-27 : 18:16:02
Don't get me wrong I can see the logic. I am just mystified about how it worked for a while then refused when some of the code was changed.

Is it just me or does VS need very specialist knowledge to get the best out of it. I can't help thinking that if QA worked the same way that all the DBA's in the world would be tearing their hair out (not that I have much)

Well done to your boys against Celtic tonight btw. Pretty impressive scoreline 5-0!! I saw Leeds play Celtic once and the fans were incredibly loud and that was just a friendly - no wonder Braveheart terrified people

cheers

steve

Alright Brain, you don't like me, and I don't like you. But lets just do this, and I can get back to killing you with beer.
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-07-28 : 05:11:33
yup it does.... i'm not saying i have it...

would be interesting though... dba's being even weirder that they are now

5-0 ehhh.... that's just nasty....

Go with the flow & have fun! Else fight the flow
Go to Top of Page
   

- Advertisement -