Sunday, July 24, 2011

Reverse the given number

Hi,
Here is the logic to reverse the given number
public
{


temp = num;

{
rev = rev * 10 + temp % 10;
temp = temp/10;
}

}
int ReverseNumber(int num)int temp = 0;int rev = 0;while (temp != 0)return rev;

Monday, July 4, 2011

adding a multiline textbox in winforms


Hi
1. Here is the code to add a multiline textbox which accepts return,tab.
2. First drag and drop a textbox from the toolbox.

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 mltext
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            textBox1.Multiline = true;

            //// setting height and width of textbox.
            textBox1.Width = 150;
            textBox1.Height = 80;
           
            //// Add vertical scroll bars to the TextBox control.
            textBox1.ScrollBars = ScrollBars.Vertical;

            //// Allow the RETURN key to be entered in the TextBox control.
            textBox1.AcceptsReturn = true;

            //// Allow the TAB key to be entered in the TextBox control.
            textBox1.AcceptsTab = true;

            //// Set WordWrap to true to allow text to wrap to the next line.
            textBox1.WordWrap = true;
        }

    }
}