Ok lets start with my problem:
First i have to write my date of birth with the following format: DD.MM.YYYY
This needs to be shown as DDMMYYYY, which means that dots must be lost. I've solved that.
This kind of number with 8 digits it needs to be converted in Binary and Hexadecimal digits.
I've done that to, all in console application.
My question is how to integrate that to wirk in a Form application. First TextBox I need to write my day of birth, in the second TextBox it mus be shown the fixed number without dots. In third one Converted to binary and in last one hexadecimal.
The code i wrote in Console application is as following:
namespace ConsoleApplication13
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Shkruaj datëlindjen tuaj");
string sHyrje = Console.ReadLine();
Console.WriteLine("Rregulluar: " + hyrja(sHyrje));
Console.WriteLine("Binar: " + DecNeBin( int.Parse(hyrja(sHyrje))));
Console.ReadLine();
int a = int.Parse(hyrja(sHyrje));
Console.WriteLine("Heksadecimal: "+a.ToString("X"));
Console.ReadLine();
}
public static string DecNeBin(int a)
{
int hyrje = a;
int[] a2 = new int[30];
a2[0] = 1;
int[] b2 = new int[30];
b2[0] = hyrje % a2[0];
int[] c2 = new int[30];
string binar = "";
for(int i=1; i<30; i++)
{
a2[i] = 2 * a2[i-1];
b2[i] = hyrje % a2[i];
c2[i - 1] = b2[i] / a2[i - 1];
}
bool flag = false;
for (int j = c2.Length; j > 0; j--)
{
if (c2[j-1] == 1)
{
flag = true;
}
if (flag)
{
binar = binar + c2[j-1];
}
}
return binar;
}
public static string DecNeHex(int a)
{
return a.ToString("X");
}
public static string hyrja(string hyrje)
{
string sHyrje = hyrje;
string sHyrjeRregulluar = "";
char c;
char[] cc;
for (int i = 0; i < sHyrje.Length; i++)
{
// Console.WriteLine(i);
c = char.Parse(sHyrje.Substring(i, 1));
cc = sHyrje.ToCharArray(i, 1);
try
{
sHyrjeRregulluar = sHyrjeRregulluar + int.Parse(c.ToString());
}
catch { }
}
return sHyrjeRregulluar;
}
}
}