Strings

 

Downloads:

strings.cs (gezipt - 2KB)
strings.exe (pseudo - 24KB)

Source:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace strings
{

/// <summary>
/// Zusammenfassung für Form1.
/// </summary>

public class Form1 : System.Windows.Forms.Form
{

private System.Windows.Forms.Button btn_end;
private System.Windows.Forms.TextBox txt_1;
private System.Windows.Forms.TextBox txt_2;
private System.Windows.Forms.Label lbl_1;
private System.Windows.Forms.Label lbl_2;
private System.Windows.Forms.Button btn_check;
private System.Windows.Forms.Label lbl_erg;

/// <summary>
/// Erforderliche Designervariable.
/// </summary>

private System.ComponentModel.Container components = null;

public Form1()
{

//
// Erforderlich für die Windows Form-Designerunterstützung
//

InitializeComponent();

//
// TODO: Fügen Sie den Konstruktorcode nach dem Aufruf von InitializeComponent hinzu
//

}

/// <summary>
/// Die verwendeten Ressourcen bereinigen.
/// </summary>

protected override void Dispose( bool disposing )
{

if( disposing )
{

if (components != null)
{

components.Dispose();

}

}
base.Dispose( disposing );

}

#region Vom Windows Form-Designer generierter Code
/// <summary>
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
/// </summary>

private void InitializeComponent()
{

this.btn_end = new System.Windows.Forms.Button();
this.txt_1 = new System.Windows.Forms.TextBox();
this.txt_2 = new System.Windows.Forms.TextBox();
this.lbl_1 = new System.Windows.Forms.Label();
this.lbl_2 = new System.Windows.Forms.Label();
this.btn_check = new System.Windows.Forms.Button();
this.lbl_erg = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// btn_end
//

this.btn_end.Location = new System.Drawing.Point(192, 216);
this.btn_end.Name = "btn_end";
this.btn_end.Size = new System.Drawing.Size(88, 32);
this.btn_end.TabIndex = 0;
this.btn_end.Text = "Ende";
this.btn_end.Click += new System.EventHandler(this.btn_end_Click);
//
// txt_1
//

this.txt_1.Location = new System.Drawing.Point(40, 40);
this.txt_1.Name = "txt_1";
this.txt_1.Size = new System.Drawing.Size(216, 20);
this.txt_1.TabIndex = 1;
this.txt_1.Text = "";
//
// txt_2
//

this.txt_2.Location = new System.Drawing.Point(40, 112);
this.txt_2.Name = "txt_2";
this.txt_2.Size = new System.Drawing.Size(216, 20);
this.txt_2.TabIndex = 2;
this.txt_2.Text = "";
//
// lbl_1
//

this.lbl_1.Location = new System.Drawing.Point(40, 16);
this.lbl_1.Name = "lbl_1";
this.lbl_1.Size = new System.Drawing.Size(216, 16);
this.lbl_1.TabIndex = 3;
this.lbl_1.Text = "1. String";
//
// lbl_2
//

this.lbl_2.Location = new System.Drawing.Point(40, 88);
this.lbl_2.Name = "lbl_2";
this.lbl_2.Size = new System.Drawing.Size(216, 16);
this.lbl_2.TabIndex = 4;
this.lbl_2.Text = "2.String";
//
// btn_check
//

this.btn_check.Location = new System.Drawing.Point(192, 176);
this.btn_check.Name = "btn_check";
this.btn_check.Size = new System.Drawing.Size(88, 32);
this.btn_check.TabIndex = 5;
this.btn_check.Text = "Check";
this.btn_check.Click += new System.EventHandler(this.btn_check_Click);
//
// lbl_erg
//

this.lbl_erg.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.lbl_erg.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, ((System.Drawing.FontStyle)(((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic)
| System.Drawing.FontStyle.Underline))), System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.lbl_erg.Location = new System.Drawing.Point(40, 168);
this.lbl_erg.Name = "lbl_erg";
this.lbl_erg.Size = new System.Drawing.Size(128, 80);
this.lbl_erg.TabIndex = 0;
this.lbl_erg.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// Form1
//

this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.lbl_erg);
this.Controls.Add(this.btn_check);
this.Controls.Add(this.lbl_2);
this.Controls.Add(this.lbl_1);
this.Controls.Add(this.txt_2);
this.Controls.Add(this.txt_1);
this.Controls.Add(this.btn_end);
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Strings";
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// Der Haupteinstiegspunkt für die Anwendung.
/// </summary>

[STAThread]
static void Main()
{

Application.Run(new Form1());

}

private void btn_end_Click(object sender, System.EventArgs e)
{

this.Close();

}

private void btn_check_Click(object sender, System.EventArgs e)
{

string t1;
string t2;
int i;
int gleiche=0;
bool heureka=false;

t1=txt_1.Text;
t2=txt_2.Text;
if(t1==t2)
{

lbl_erg.Text="gleich";
heureka=true;

}
else
{

for(i=0;i<=t2.Length-t1.Length;i++)
{

if(0==String.Compare(t1,t2.Substring(i,t1.Length)))
{

lbl_erg.Text="1 in 2 enthalten";
heureka=true;

}

}

}
if(t1.Length==t2.Length)
{

for(i=0;i<t1.Length;i++)
{

if(t1[i]==t2[i])
{

gleiche++;

}

}
if(gleiche==t1.Length-1)
{

lbl_erg.Text="Fast gleich!";
heureka=true;

}

}
if(!heureka)
{

lbl_erg.Text="Keine Ähnlichkeit!";

}

}

}

}

<<zurück>>