Nebolsoe zdanie na C#
#1
Отправлено 22 мая 2007 - 18:52
Помогите кто-нибудь решить вот такое задание..
1. Сщздать форму на ней ТекстБокс, куда будете вводить псевдоним С#,
рядом будет распологаться кнопка поиска псевдонима, а ниже Label,
куда будет распечатываться результат поиска.
2. Ниже приведён код файла, где будет искаться псевдоним.
sbyte - znakovoje 8-bitovoje 4islo
byte - bezznakovoje 8-bitovoje 4islo
int - bezznakovoje 16-bitovoje 4islo
long bezznakovoje 64-bitovoje 4islo
ZARANEE SPASIBO!
#3
Отправлено 23 мая 2007 - 17:42
вот где "//" напишите пожалуйста что эта функция делает.
InitializeComponent();
Text = "Za4et";
b1.Click += new EventHandler(On_Click); //
}
void On_Click(object sender, EventArgs e)
{
l1.Text = "";
string input = null; //
StreamReader sr = File.OpenText("1.txt"); //
while ((input = sr.ReadLine()) != null) //
{
if(input=="#"+tb1.Text)
while (input != "")
{
l1.Text += input + "\r\n"; //
input = sr.ReadLine();
}
}
sr.Close();
}
static void Main()
{
Application.Run(new MyForm());
}
private void InitializeComponent()
{
this.b1 = new System.Windows.Forms.Button(); //
this.tb1 = new System.Windows.Forms.TextBox();
this.l1 = new System.Windows.Forms.Label();
this.SuspendLayout();
this.b1.Location = new System.Drawing.Point(35, 90); //
this.b1.Name = "button";
this.b1.Size = new System.Drawing.Size(75, 20);
this.b1.TabIndex = 0; //
this.b1.Text = "Poisk";
this.b1.UseVisualStyleBackColor = true;
this.tb1.Location = new System.Drawing.Point(30, 50);
this.tb1.Name = "tb";
this.tb1.Size = new System.Drawing.Size(100, 20);
this.tb1.TabIndex = 1;
this.l1.BackColor = System.Drawing.SystemColors.ButtonHighlight; //
this.l1.Location = new System.Drawing.Point(30, 140);
this.l1.Name = "label"; //
this.l1.Size = new System.Drawing.Size(240, 120);
this.l1.TabIndex = 2; //
this.ClientSize = new System.Drawing.Size(290, 265); //
this.Controls.Add(this.l1);
this.Controls.Add(this.tb1); //
this.Controls.Add(this.b1);
this.Name = "MyForm";
this.ResumeLayout(false); //
this.PerformLayout();
Благодарю за помощь заранее !
#4
Отправлено 24 мая 2007 - 11:09
Вобщем задание сделано, помогите теперь поставить комментарии к функциям,
вот где "//" напишите пожалуйста что эта функция делает.
InitializeComponent();
Text = "Za4et";
b1.Click += new EventHandler(On_Click); // для события Click кнопки вызывается обработчик
}
void On_Click(object sender, EventArgs e)
{
l1.Text = "";
string input = null; // если ничего нет null-пустое значение
StreamReader sr = File.OpenText("1.txt"); // открываем текстовый файл
while ((input = sr.ReadLine()) != null) // пока можно читать из него (пока там есть текст)
{
if(input=="#"+tb1.Text)
while (input != "")
{
l1.Text += input + "\r\n"; //после каждой прочитанной строки ставим переход на другую строку - \n, а что такое \r - не знаю
input = sr.ReadLine();
}
}
sr.Close();
}
static void Main()
{
Application.Run(new MyForm());
}
private void InitializeComponent()
{
this.b1 = new System.Windows.Forms.Button(); // объявляктся кнопка
this.tb1 = new System.Windows.Forms.TextBox();
this.l1 = new System.Windows.Forms.Label();
this.SuspendLayout();
this.b1.Location = new System.Drawing.Point(35, 90); // определяутся месторасположение
this.b1.Name = "button";
this.b1.Size = new System.Drawing.Size(75, 20);
this.b1.TabIndex = 0; // можно переходить, нажимая клавишу Tab . Это будет первая кнопка, на которую будет переходить таб.
this.b1.Text = "Poisk";
this.b1.UseVisualStyleBackColor = true;
this.tb1.Location = new System.Drawing.Point(30, 50);
this.tb1.Name = "tb";
this.tb1.Size = new System.Drawing.Size(100, 20);
this.tb1.TabIndex = 1;
this.l1.BackColor = System.Drawing.SystemColors.ButtonHighlight; // определяем задний фон
this.l1.Location = new System.Drawing.Point(30, 140);
this.l1.Name = "label"; // в качестве имени задаём своё имя
this.l1.Size = new System.Drawing.Size(240, 120);
this.l1.TabIndex = 2; // переход по нажатии клавиши таб. (уже третий, т.к. индекс 2, у первого 0)
this.ClientSize = new System.Drawing.Size(290, 265); // размер формы
this.Controls.Add(this.l1);
this.Controls.Add(this.tb1); // в контролы добавляем эти кнопки
this.Controls.Add(this.b1);
this.Name = "MyForm";
this.ResumeLayout(false); //
this.PerformLayout();
Благодарю за помощь заранее !