How To Make A Captcha Generator In VB.NET

We all know what is captcha if you don't know what is, captcha is a word test or more than one word test that is mixed and cannot identify easily that is used to verify human. Okay now we are going to make it first you need to add a class so go ahead and add a class and add the codes below to the class.





Imports System.Text
Imports System.Drawing
Imports System.Windows.Forms
Imports System.Drawing.Drawing2D

Class Captcha

    Inherits PictureBox
    Public randomstr As String
#Region "Properties"
    Private _textcolor As Color = Color.Black
    Public Property TextColor() As Color
        Get
            Return _textcolor
        End Get
        Set(ByVal value As Color)
            _textcolor = value
            Invalidate()
        End Set
    End Property

    Private _font As New Font("Segoe UI", 20)
    Public Overrides Property Font() As Font
        Get
            Return _font
        End Get
        Set(ByVal value As Font)
            _font = value
            Invalidate()
        End Set
    End Property

    Private _texttouse As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmopqrstuvwxyz1234567890"
    Public Property RandomCharacters() As String
        Get
            Return _texttouse
        End Get
        Set(ByVal value As String)
            _texttouse = value
            Invalidate()
        End Set
    End Property

    Private _captchalength As Integer = 8
    Public Property CaptchaTextLength() As Integer
        Get
            Return _captchalength
        End Get
        Set(ByVal value As Integer)
            _captchalength = value
            Invalidate()
        End Set
    End Property

    Private _numberoflines As Integer = 50
    Public Property NumberOfLines() As Integer
        Get
            Return _numberoflines
        End Get
        Set(ByVal value As Integer)
            _numberoflines = value
            Invalidate()
        End Set
    End Property
#End Region

#Region "Events"
    Public Sub New()
        SetStyle(ControlStyles.AllPaintingInWmPaint, True)
        SetStyle(ControlStyles.ResizeRedraw, True)
        SetStyle(ControlStyles.UserPaint, True)
        SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
        SetStyle(ControlStyles.SupportsTransparentBackColor, True)
    End Sub

    Protected Overrides Sub CreateHandle()
        MyBase.CreateHandle()
        Me.Size = New Size(241, 69)
        Me.BorderStyle = BorderStyle.FixedSingle
    End Sub

    Public CaptchaText As String = String.Empty
    Private rnd As New Random()
    Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
        Dim B As New Bitmap(Width, Height)
        Dim G As Graphics = Graphics.FromImage(B)

        Dim BoxSize As New Rectangle(0, 0, Me.Width, Me.Height)
        Dim txtcolor As Brush = New SolidBrush(Color.FromArgb(rnd.[Next](160, 255), _textcolor))
        G.SmoothingMode = SmoothingMode.HighQuality

        G.Clear(BackColor)

        For I As Integer = 0 To _numberoflines - 1
            G.DrawLine(New Pen(Color.FromArgb(rnd.[Next](128, 255), CreateRandomColor())), rnd.[Next](0, BoxSize.Width), rnd.[Next](0, BoxSize.Height), rnd.[Next](BoxSize.Width), rnd.[Next](BoxSize.Height))
        Next

        Dim SFormat As New StringFormat()
        SFormat.Alignment = StringAlignment.Center
        SFormat.LineAlignment = StringAlignment.Center

        G.RotateTransform(rnd.[Next](-7, 7), MatrixOrder.Append)

        randomstr = CreateRandomString()
        G.DrawString(randomstr, Font, txtcolor, BoxSize, SFormat)
        CaptchaText = randomstr

        e.Graphics.DrawImage(B, 0, 0)
        G.Dispose()
        B.Dispose()
    End Sub
#End Region

#Region "Create Randoms"
    Private Function CreateRandomColor() As Color
        Return Color.FromArgb(100, rnd.[Next](255), rnd.[Next](255), rnd.[Next](255))
    End Function

    Private Function CreateRandomString() As String
        Dim buffer As Char() = New Char(_captchalength - 1) {}
        For i As Integer = 0 To _captchalength - 1
            If _texttouse = String.Empty Then
                Dim newtext As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmopqrstuvwxyz1234567890"
                buffer(i) = newtext(rnd.[Next](newtext.Length))
            Else
                buffer(i) = _texttouse(rnd.[Next](_texttouse.Length))
            End If
        Next
        Return New String(buffer)
    End Function
#End Region
End Class

How To Create And Write A Text File In Java

We will see how to create and write a text file in java so basically you get the idea after reading the title whatever when you run this program it creates a txt file and write some text inside so lets start making it , i am doing this in text editor so it's good id you also use a text editor ok now create a class and add the namespace io import java.io.*; and now write down the public static void main(String args[]) by the way don't forget to add the tags ({) now write down FileOutputStream Create; after that write this PrintStream Write; alright i will just put here the whole codes to make it easier for you

import java.io.*;
public class Create_txt 
{ 

 public static void main(String args[])
   {
    FileOutputStream Create;
    PrintStream Write;
    try
   {
    Create = new FileOutputStream("Text.txt");

    Write = new PrintStream( Create );

    Write.println ("Ultimate programming tutorials");

    Write.close();
    } 
    catch (Exception e)
    {
   System.err.println ("Cannot write txt file");
   }
  }
}

now when you run a new txt file will be created named "Text.txt" and Ultimate programming tutorials will be there inside the txt file if something stopped the process you will see "Cannot write txt file" in the console , i hope this is useful.

How To Count Number Of Characters Using html and Javascript

hello guys , i have had an idea to make something what the title says so on i am here with a small tutorial on making what the title says . we will be using html and javascript by the waythe whole code is just 20 lines including html tags ok now open your favorite text editor and create the html tags (html,head,body) after that  go under head tag and we will use a function so put these



alright now go under body tag and put these

Insert text to You want to count:
ok now save it as you want dont forget to give the extension to php or html , i recommend php

here is a preview of what you created



How To Make A Hangman Game In C#

hello everyone,everyone loves game except me so i thought to make a tutorial about making a hangman game in c# and it's command line application since its simple. i guess some people dont know what is hangman ok actually what is hangman ?
it is a paper and pencil guessing game for two or more players. One player thinks of a word, phrase or sentence and the other tries to guess it by suggesting letters or numbers.Wikipedia

sounds like a interesting game :) , now lets start working on start a new project a console application and you will be falling in to the coding spot and add all the codes

Radial/Circular Progressbar Control For VB.NET


hey guys , after you may have seen this post circular progressbar but it's just drawing graphics on the form , now i have got something that's really a progressbar control :) so you can see a GIF image that i have recorded to show you all how the progressbar works . this is not a DLL this is just a class so when you are on a project add a class and put the codes you see below and build your program and you will see this in the toolbox


Matrix Effect In C/C++

matrix
First open your c++ IDE. after that create a new project and put these codes inside.
#include 
#include 
#include 
#include 
using namespace MatrixC;

int main()
{
   system("color 0a");
   srand(time(0));
   char random_char = ((rand() % 127));
   bool going = true, checking = true;

   while (going = true)
   {
   
      for (int x = 0; x < 38; x++)
      {
                  random_char = ((rand() % 127) + 50);
         checking = true;
         while (checking)
         {
            if  ( 
               
                  (random_char == 32) || (random_char == 39) || (random_char == 46) ||
                  (random_char == 44) || (random_char == 34) || (random_char == 45) ||
                  (random_char == 58) || (random_char == 59) || (random_char == 94) ||
                  (random_char == 95) || (random_char == 96) || (random_char == 126)
               
                )
            random_char = ((rand() % 127) + 50);
                                 else break;
         }
                 cout << random_char << " ";
      }
          cout << endl;
        
         Sleep(20);
   }
   cin.get();
   return 0;
}
The includes are the namespaces in c++ , the code system("color 0a"); is the green color text of our Matrix effect (color oa is the system name for green) ,  srand(time(0)); is the random speed , for (int x = 0; x < 38; x++) draws the rows of characters , random_char = ((rand() % 127) + 50); checking = true; while (checking) generates the first character ,

 this (random_char == 32) || (random_char == 39) || (random_char == 46) || (random_char == 44) || (random_char == 34) || (random_char == 45) || (random_char == 58) || (random_char == 59) || (random_char == 94) || (random_char == 95) || (random_char == 96) || (random_char == 126) checks for bad characters ,

this random_char = ((rand() % 127) + 50); generates random characters if bad characters generated , this else break; will continue to print if good characters generated , this cout << random_char << " "; prints character , this  cout << endl; if full characters were printed will continue to next row , this delays Sleep(20); .

You can see a preview of the matrix on top of this post.

How To Use Advanced Encryption Standard(AES) In C#


hey everyone , i got something interesting now :) ok now what is Advanced Encryption Standard(AES)
The Advanced Encryption Standard (AES) is a specification for the encryption of electronic data established by the U.S. National Institute of Standards and Technology (NIST) in 2001.Based on the Rijndael cipher developed by two Belgian cryptographers, Joan Daemen and Vincent Rijmen, who submitted a proposal which was evaluated by the NIST during the AES selection process.-Wikipedia
ok now you know AES lets try it in visual c# . create a console application and name it :) now here is my codes

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
using System.IO;

//Author : Mohamed Shimran
//Blog : http://www.ultimateprogrammingtutorials.blogspot.com

namespace AES
{
    class Program
    {
        static void Main(string[] args)
        {
            UTF8Encoding UTF8 = new UTF8Encoding();

            Console.WriteLine("Shims Encryption UPT");

            string text = "Ultimate programming tutorials";
            byte[] txt = UTF8.GetBytes(text);
            Console.WriteLine("Text: " + text);

            AesCryptoServiceProvider aes = new AesCryptoServiceProvider();
            byte[] key = aes.Key;
            byte[] iv = aes.IV;
            
            byte[] n;

            ICryptoTransform ict = aes.CreateEncryptor(key, iv);

            MemoryStream ms = new MemoryStream();

            CryptoStream cs = new CryptoStream(ms, ict, CryptoStreamMode.Write);

            StreamWriter sw = new StreamWriter(cs);
            sw.Write(text);
            sw.Close();

            n = ms.ToArray();

            Console.WriteLine("Encrypted : " + Convert.ToBase64String(n));

            ICryptoTransform icrt = aes.CreateDecryptor(key, iv);

            MemoryStream mms = new MemoryStream(n);

            CryptoStream cts = new CryptoStream(mms, icrt, CryptoStreamMode.Read);

            StreamReader sr = new StreamReader(cts);

            Console.WriteLine("Decrypted : " + sr.ReadToEnd());

            sr.Close();

            aes.Clear();
            Array.Clear(key, 0, key.Length);
            Array.Clear(iv, 0, iv.Length);

            Console.Read();
        }
    }
}

now string text is your text that is going to be encrypted using the program so replace Ultimate programming tutorials and now debug the program and you will the text encrypted and the text decrypted . how awesome :)

How To Make A Simple Magnifier In C#

Today we are going to make a simple magnifier in visual c# so let's continue. If you don't know what is a magnifier?.
A screen magnifier is software that interfaces with a computer's graphical output to present enlarged screen content. It is a type of assistive technology suitable for visually impaired people with some functional vision; visually impaired people with little or no functional vision usually use a screen reader. Wikipedia
Actually we are going to make a screen magnifier not just a magnifier the word magnifier refers to a scientific instrument.


How To End Process Using C#

end process

This is a very nice tutorial and very useful in the same time and i am not going to make it so hard since you should learn the basics first ok now you need to create a new project and name the project and after creating the project you should set up the normal things you do and after that i am using a button and a text box so just go ahead and add a button and text box and change the text property of button to "end process" or whatever now when you put the process name in the text box and press the button that process will be ended .

here is the codes

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;
using System.Diagnostics;

//Author : Mohamed Shimran
//Blog : Http://www.ultimateprogrammingtutorials.blogspot.com

namespace EndProcess
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
       
        private void button1_Click(object sender, EventArgs e)
        {

            Process[] ps = Process.GetProcesses();
            foreach (Process p in ps)
            {
                if (p.ProcessName.ToLower() == textBox1.Text )
                {
                    p.Kill();
                }

            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        
    }
}


enjoy and try to make it more stable since its not stable

How To Empty Recycle Bin Using C#


hey everyone , we going to learn how to empty the recycle bin using c# this pretty an easy way out . you just need to a button or lets say click event or anything that can do something now you just have to add this codes into your form1 code , i will put whole of my codes here so i am using a button to do the work

here is the codes


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;
using System.Runtime.InteropServices;

//Author : Mohamed Shimran
//Blog : http://www.ultimateprogrammingtutorials.blogspot.com

namespace RecycleBin
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        enum RecycleFlags : uint
        {
            SHERB_NOCONFIRMATION = 0x00000001,
            SHERB_NOPROGRESSUI = 0x00000001,
            SHERB_NOSOUND = 0x00000004
        }

        [DllImport("Shell32.dll", CharSet = CharSet.Unicode)]
        static extern uint SHEmptyRecycleBin(IntPtr hwnd, string pszRootPath,
        RecycleFlags dwFlags);
               private void button1_Click(object sender, EventArgs e)
        {
            uint result = SHEmptyRecycleBin(IntPtr.Zero, null, 0);
        }
    }
}
enjoy

How To Make A Sound Recorder In C#

sound recorder

hey ,today i will let you know how to create a sound recorder in c# by the way this is just a simple tutorial but this will let you know about the recording so you can make a  advanced recording application ok now first create a new project and name it and you need three buttons and one label so drag and and drop them from tool box into your form and now change the text of the each button as below

Button 1 - Record
Button2 - Stop And Save
Button3 - Play

now just keep the label 1 text empty now just double click your form and erase everything and add the whole code there

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;
using System.Runtime.InteropServices;

//Author : Mohamed Shimran
//Blog : http://www.ultimateprogrammingtutorials.blogspot.com

namespace soundrecorder
{
    public partial class Form1 : Form
    {
        [DllImport("winmm.dll")]
        private static extern int mciSendString(string MciComando, string MciRetorno, int MciRetornoLeng, int CallBack);

        string musica = "";
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            label1.Visible = true;
            mciSendString("open new type waveaudio alias Som", null, 0, 0);
            mciSendString("record Som", null, 0, 0);
        
        }

        private void button2_Click(object sender, EventArgs e)
        {
            label1.Visible = false;
            mciSendString("pause Som", null, 0, 0);

          

            SaveFileDialog save = new SaveFileDialog();

            save.Filter = "wave|*.wav";


            if (save.ShowDialog() == DialogResult.OK)
            {

                mciSendString("save Som " + save.FileName, null, 0, 0);
                mciSendString("close Som", null, 0, 0);
            }
            
        }

        private void button3_Click(object sender, EventArgs e)
        {
            if (musica == "")
            {
                OpenFileDialog open = new OpenFileDialog();
                open.Filter = "Wave|*.wav";
                if (open.ShowDialog() == DialogResult.OK) { musica = open.FileName; }
            }
            mciSendString("play " + musica, null, 0, 0);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            label1.Visible = false;
        }


    }
}


now debug and enjoy .