Showing posts with label own. Show all posts
Showing posts with label own. Show all posts

Wednesday, March 28, 2012

Substring of text...

OK, this probably is a question with a very simple answer, though I seem to be unable to find it... I'm creating my own weblog at the moment, and on the main page I would like to put a substring of the day's text ,until the first dot.

This is the code I've been trying to use :

Dim logText As String = qWebLog.myDataReader("msgText")
logText = logText.Substring(0, logText.indexOf("."))
logBodyCell.Text = logText & " <a href='?logID=" & qWebLog.myDataReader("ID") _
& "'>Read more ...</a>"

To illustrate : it should put the text in the cell till the first occurence of the dot (the end of the first sentence in other words... Though this code doesn't work, he gives the following error : length cannot be less than zero : paramatername = length.

Though, the text contains a dot ...

Who could help me please?

Regards,
NielsThe text cannot contain a dot if the error is occuring. I would suggest that you do the following:

String logText = qWebLog.myDataReader("msgText");

Int IndexOfDot = logText.IndexOf(".");

if (IndexOfDot > -1) {

logText = logText.Substring(0, IndexOfDot);
}

logBodyCell.Text = logText + " <a href='?logID=" + qWebLog.myDataReader("ID") + "'>Read more ...</a>";


Thanks a lot ! That worked ...

But now (sorry for my questioning...) I have the same problem when I type three dots... I tried it the same way :


Dim logText As String = qWebLog.myDataReader("msgText")
Dim IndexOfDot As Integer = logText.IndexOf(".")
Dim IndexOfTripleDot As Integer = logText.IndexOf("...")
If IndexOfDot > -1 Then
logText = logText.Substring(0, IndexOfDot + 1)
logBodyCell.Text = logText & " <a href='?logID=" & qWebLog.myDataReader("ID") _
& "'>Read more ...</a>"
ElseIf IndexOfTripleDot > -1 Then
logText = logText.Substring(0, IndexOfTripleDot + 1)
logBodyCell.Text = logText & " <a href='?logID=" & qWebLog.myDataReader("ID") _
& "'>Read more ...</a>"
Else
logBodyCell.Text = logText & " <a href='?logID=" & qWebLog.myDataReader("ID") _
& "'>Read more ...</a>"
End If

And it still doesn't work...

Sorry for the silly questions ...

Regards and a early happy newyear !

Regards
IndexOfDot will always be greater the -1 if IndexOfTripleDot is greater than -1, therefore the second condition will never be tested. Reverse the order of your if statements.

Also, you have six lines that do exactly the same thing. The following will achieve the same result, but with less lines of code:

Dim logText As String = qWebLog.myDataReader("msgText")

Dim IndexOfDot As Integer = logText.IndexOf(".")
Dim IndexOfTripleDot As Integer = logText.IndexOf("...")

If IndexOfTripleDot > -1 Then
logText = logText.Substring(0, IndexOfTripleDot + 1)
ElseIf IndexOfDot > -1 Then
logText = logText.Substring(0, IndexOfDot + 1)
End If

logBodyCell.Text = logText & " <a href='?logID=" & qWebLog.myDataReader("ID") _
& "'>Read more ...</a>"

Sudden VS2003 Error

I was going along just fine developing an ASP.NET application using IIS on
my own machine. I had to reboot. When I came back, VS started acting
flakey. It would not reload my project claiming that it could not connect
to the url on my machine (something like http://localhost/myApplication).
"A connection with the server could not be established"
I tried this:
1) backed up all files
2) deleted the project folder from wwwroot
3) created a new web application in visual studio using the same name
4) copied all the source code files (no project or solution) into that
folder and added them to the new project
Worked fine at first and built just fine, but when I exited VS and came back
it would no longer load either.
Caveat 1: When I rebooted I changed my network password, but I don't expect
this should matter in any way.
Caveat 2: I am running McAfee Anti-Virus (required by the site whose machine
this actually is).
Tried to google the error for a solution, but nothing seems to fix it.
Any takers?Hi
There are known problems with McAfee and VS.NET.
If you are forced to use McAfee make sure the "buffer overload" option
is off.
Good luck.
Regards,
Daniel Roth
MCSD.NET
Dan,
I'll disable it, but can you tell me what effect it had on you, or how you
figured out that it was the problem?
<dan.c.roth@.gmail.com> wrote
> There are known problems with McAfee and VS.NET.
> If you are forced to use McAfee make sure the "buffer overload" option
> is off.

Sudden VS2003 Error

I was going along just fine developing an ASP.NET application using IIS on
my own machine. I had to reboot. When I came back, VS started acting
flakey. It would not reload my project claiming that it could not connect
to the url on my machine (something like http://localhost/myApplication).

"A connection with the server could not be established"

I tried this:
1) backed up all files
2) deleted the project folder from wwwroot
3) created a new web application in visual studio using the same name
4) copied all the source code files (no project or solution) into that
folder and added them to the new project

Worked fine at first and built just fine, but when I exited VS and came back
it would no longer load either.

Caveat 1: When I rebooted I changed my network password, but I don't expect
this should matter in any way.
Caveat 2: I am running McAfee Anti-Virus (required by the site whose machine
this actually is).

Tried to google the error for a solution, but nothing seems to fix it.

Any takers?Hi

There are known problems with McAfee and VS.NET.

If you are forced to use McAfee make sure the "buffer overload" option
is off.

Good luck.

Regards,
Daniel Roth
MCSD.NET
Dan,

I'll disable it, but can you tell me what effect it had on you, or how you
figured out that it was the problem?

<dan.c.roth@.gmail.com> wrote
> There are known problems with McAfee and VS.NET.
> If you are forced to use McAfee make sure the "buffer overload" option
> is off.

Monday, March 26, 2012

suggestion for improvement

hey all,
in regards to the visual studio code editor (for any language), and in
additon to auto outlining it would be nice if we could hide our own lines of
code at the same time.
i know you can say stop auto outlining and then do the hiding but doing both
would be great and in addition to that to somehow persist the custom
outlining.
hope i haven't went overboard.
thanks,
rodcharrodchar,
The Product Feedback Site is the place. You can also search it to see if
anyone else has made a similar suggestion, and you can track the results of
your input.
Cheers,
Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"rodchar" wrote:

> hey all,
> in regards to the visual studio code editor (for any language), and in
> additon to auto outlining it would be nice if we could hide our own lines
of
> code at the same time.
> i know you can say stop auto outlining and then do the hiding but doing bo
th
> would be great and in addition to that to somehow persist the custom
> outlining.
> hope i haven't went overboard.
> thanks,
> rodchar

suggestion for improvement

hey all,
in regards to the visual studio code editor (for any language), and in
additon to auto outlining it would be nice if we could hide our own lines of
code at the same time.

i know you can say stop auto outlining and then do the hiding but doing both
would be great and in addition to that to somehow persist the custom
outlining.

hope i haven't went overboard.

thanks,
rodcharrodchar,
The Product Feedback Site is the place. You can also search it to see if
anyone else has made a similar suggestion, and you can track the results of
your input.
Cheers,
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"rodchar" wrote:

Quote:

Originally Posted by

hey all,
in regards to the visual studio code editor (for any language), and in
additon to auto outlining it would be nice if we could hide our own lines of
code at the same time.
>
i know you can say stop auto outlining and then do the hiding but doing both
would be great and in addition to that to somehow persist the custom
outlining.
>
hope i haven't went overboard.
>
thanks,
rodchar