473,396 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Text problem

First i must say i am sorry for the repost. I noticed to late that i forgot
to add text in the subject field.

I made a class that has one purpose. That is to read a log file into an
array and provide methods to get a random line. In the code below I am using
GetHeaderFromFiles to build up the array. In getDateStart i am picking out
line 2 from the array. When i in some form try to set a textbox.text like
this it does not work :
-----------------------------------------
LogHead test = new LogHead();
txtDate.Text = test.getDateStart();
-------------------------------------------
Here is the class LogHead

public static string GetHeaderFromFile(string filename, int linenr)
{
StreamReader f = new StreamReader(filename);
ArrayList lines = new ArrayList();
string line;
while ((line = f.ReadLine()) != null)
lines.Add(line);
return lines[linenr].ToString();
}
public static string getDateStart()
{
string theDate=GetHeaderFromFile(@"C:\Log\log.dat", 2);
return theDate;
}

As a newbee i am wondering why this does not work and if someone has some
tip that can help
me.
Best regards

Nov 16 '05 #1
1 1025
Your methods are static, but you are creating an instance when calling
getDateStart()...
I'm not even sure how in the heck that is working for you.

txtDate.Text = LogHead.getDateStart(); // This is how you call statics.

Unless GetHeaderFromFile is caching, then you should be reading lines only up to
the
line you actually want. That way you don't run the risk of accessing an index
outside of
the lines buffer, and you don't wind up reading in lines you simply don't need.
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers
"Trond" <th******@broadpark.no> wrote in message
news:41******@news.broadpark.no...
First i must say i am sorry for the repost. I noticed to late that i forgot to
add text in the subject field.

I made a class that has one purpose. That is to read a log file into an
array and provide methods to get a random line. In the code below I am using
GetHeaderFromFiles to build up the array. In getDateStart i am picking out
line 2 from the array. When i in some form try to set a textbox.text like
this it does not work :
-----------------------------------------
LogHead test = new LogHead();
txtDate.Text = test.getDateStart();
-------------------------------------------
Here is the class LogHead

public static string GetHeaderFromFile(string filename, int linenr)
{
StreamReader f = new StreamReader(filename);
ArrayList lines = new ArrayList();
string line;
while ((line = f.ReadLine()) != null)
lines.Add(line);
return lines[linenr].ToString();
}
public static string getDateStart()
{
string theDate=GetHeaderFromFile(@"C:\Log\log.dat", 2);
return theDate;
}

As a newbee i am wondering why this does not work and if someone has some tip
that can help
me.
Best regards

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Srinath Avadhanula | last post by:
Hello, Sorry to be bringing up what seems to be a somewhat beaten up topic... This is what I wanted to do: Create a _simple_ text editor widget which supports VI(M) style keybindings but...
19
by: Svennglenn | last post by:
I'm working on a program that is supposed to save different information to text files. Because the program is in swedish i have to use unicode text for ÅÄÖ letters. When I run the following...
0
by: Pierre Jelenc | last post by:
I have a blog script that is a customized version of Word Press (wordpress.org) at http://www.web-ho.com/blog/ Because of the way it evolved, some of the CSS may not be the best, I have tended...
5
by: Harry | last post by:
CSS Description: Table contains a column of td cells with links. Achieved: 1. Entire link cells highlight when hovered. 2. The entire area of these cells are clickable. Problem:
12
by: who be dat? | last post by:
I'm trying to make a webpage do the following: I want a user to be able to click on a given image (there will be more than one image). Upon clicking a given image, characters specific to that...
3
by: Jan Krouwer | last post by:
I have a problem that shows up only on some systems - the toolbar text in buttons is not visible (vb.net 2003 app, 1.1 framework). As a workaround, I changed the textalign property to "right". This...
1
by: svijay | last post by:
hi I have got a strange problem. May I know any solution for this. Here is the detailed description about the problem We have got a mainframe system and also production and development...
14
by: Roger Withnell | last post by:
How to I find out what size text the browser is set to? Thanks in anticipation.
4
by: Steven Bethard | last post by:
I have some plain text data and some SGML markup for that text that I need to align. (The SGML doesn't maintain the original whitespace, so I have to do some alignment; I can't just calculate the...
2
by: DragonShade | last post by:
To be honest, I'm not sure if this is a .NET issue, some configuration on a PC, or a setting in a database but here goes: Environment (have NO control over): XP (London & Tokyo),.NET 2.0 C#, 2...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.