19 Mart 2015 Perşembe

c# textboxa girdiğimiz karakter ve kelime sayısını bulan program



KOD KISMI:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace KELİME_VE_KARAKTER_SAYISI_ÖRNEĞİ
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
     
        private void button2_Click(object sender, EventArgs e)
        {
            //TEMİZLE BUTONU İLE TEXTBOX VE LABELLERİ TEMİZLİYORUZ..

            label3.Text = string.Empty;
            label4.Text = string.Empty;
            textBox1.Text = string.Empty;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            // BURADA KARAKTER SAYISINI TEXTBOXA GİRDİĞİMİZ KARAKTER SAYISININ UZUNLUĞUNA EŞİTLEDİK.
         
            label4.Text = textBox1.TextLength.ToString();
            string a;
            a = Convert.ToString(textBox1.Text);
            int sayac = 0;
            int b;
            b = textBox1.TextLength;
         
         

         
            for (int i = 0; i < b; i++)
            {
             
                // BURADA "İ" BOŞLUĞA EŞİT OLDUĞU ZAMAN KELİME SAYISINI 1 ARTIRMASINI İSTEDİK.
                if (textBox1.Text.Substring(i, 1) == " ")
                {
                    sayac++;
               
                }


            }

            label3.Text = (sayac + 1).ToString();




        }
    }
}

YAPIM --> FURKAN ÇEBİ

Hiç yorum yok: