vb.net / asp.net label.visible depending on string length

windows

Guest
This code reads the text file fine and it adds the trailing dots at the end.
What I'm trying to figure out now is how make a label.visible = false if the only thing passing to the label is "..."
If there's no text going to the label, then I want the label.visible = false. The problem is the label shows up no matter what.
I've tried setting visible to false if the strShortContentONE length is zero, is nothing, etc... tried by setting visible to false if label.text = "" or label.text = "...". I've tried so many different things I can't even remember them all. I'm not a very advanced coder yet, so my best guess is that the buffer is the problem. Anyone help?


Dim fsONEreader As New System.IO.FileStream("C:\Documents and Settings\ONE.txt", IO.FileMode.Open)
Dim bufferONEreader(100) As Byte ' 100=> number of characters to be read
'ONE label - Reading text file
fsONEreader.Read(bufferONEreader, 0, 100)
fsONEreader.Close()
Dim ONEtext() As Char = System.Text.Encoding.ASCII.GetChars(bufferONEreader)
Dim strShortContentONE As String = New String(ONEtext)
' converting old string to new string to add trailing dots
Dim strShortContentONEdots As String = strShortContentONE.Substring(0, 100)
Dim lastSpaceONE As String = strShortContentONEdots.LastIndexOf("")
If (lastSpaceONE <= 100) Then
strShortContentONEdots = strShortContentONEdots.Substring(0, lastSpaceONE)
'add "..." at the end
strShortContentONEdots += "..."
End IfTry something like this intead.


<%
TRY
Dim StrSource as String
Dim SR as System.IO.StreamReader = new System.IO.StreamReader("c:\inetpub\wwwroot\txt.txt")
For Idx as Integer = 0 to 99
if SR.Peek() >= 0 Then strsource &= convert.tochar(SR.Read()) Else Exit For
Next
SR.Close()

StrSource = StrSource.Trim()

If (StrSource.Length <= 100) Then
StrSource &= "..."
End If

If strsource.endswith("...") Then response.write("Yes<br />") Else response.Write("No<br />")

response.write(StrSource.Length & "<br />" & strsource)

CATCH EX AS EXCEPTION
response.write(ex.tostring)
END TRY
%>
 
Back
Top