Opening New Window
FrmCupsToOunces MyNewForm = new FrmCupsToOunces();
MyNewForm.Show();
Making Array
const int QUARTERS = 4;
const int DIVISIONS = 3;
double[,] stats = new double[DIVISIONS, QUARTERS];
Making Password Check
int InNumTry = 0;
private void BtnGo_Click_1(object sender, EventArgs e)
{
string password;
password = TxtIn.Text;
switch (password)
{
case " ": MessageBox.Show("Passowrd is empty.");
break;
case "MIKE": MessageBox.Show("Password is OK!");
FrmBOO newForm = new FrmBOO();
newForm.Show();
break;
default:
InNumTry++;
MessageBox.Show("Invalid Passwrod, try again!");
TxtIn.Text = "";
TxtIn.Focus();
break;
}
Check Length
LblLength.Text = TxtInput.Text.Length.ToString();
Make To Upper
LblUpper.Text = TxtInput.Text.ToUpper();
Make To Lower
LblLower.Text = TxtInput.Text.ToLower();
Last Right Three
LblRight.Text = TxtInput.Text.Substring(TxtInput.Text.Length - 3);
Show Middle Characters
LblSubscript.Text = TxtInput.Text.Substring(1, 3);
ASCII
private void btnascii_Click(object sender, EventArgs e)
{
string assqui;
int num;
num = Convert.ToInt32(txtinput.Text);
assqui = char.ConvertFromUtf32(num);
lblascii.Text = assqui.ToString();
}
CONVERT A CHARACTER TO ASCII
string assqui;
int num;
num = Convert.ToInt32(textBox1.Text);
assqui= char.ConvertFromUtf32(num);
lblout.Text = assqui.ToString();
Show Difference
string name;
name = txtinput.Text;
foreach (char letter in name)
{
MessageBox.Show(letter.ToString());
}
Get File
private void BtnGetFile_Click(object sender, EventArgs e)
{
string Line;
int count = 0;
try
{
StreamReader ReadFile;
StringFileName = Interaction.InputBox(" Please Enter Your Desired File Name \n You do not need to place the '.txt' at the end of the file name.") + ".txt";
ReadFile = File.OpenText(StringFileName);
LbSongs.Items.Clear();
while (!ReadFile.EndOfStream)
{
Line = ReadFile.ReadLine();
string[] words = Line.Split(',');
ListSongs[count].NameOfSong = words[0];
ListSongs[count].NameOfArtist = words[1];
ListSongs[count].NameOfFile = words[2];
ListSongs[count].ThisWeekRank = words[3];
ListSongs[count].MostWeekRank = words[4];
ListSongs[count].LastWeekRank = words[5];
LbSongs.Items.Add(ListSongs[count].NameOfSong);
count++;
}
LbSongs.SelectedIndex = 0;
Show();
ReadFile.Close();
}
catch
{
MessageBox.Show("The file you are trying to access either, can not be found or opened");
}
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
private void infoToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("The Program was created by Konrad Lazarek.\n\nOn April 16st, 2014.\n\nVersion: 00:03:48:59",
"Info On This Program",
MessageBoxButtons.OK,
MessageBoxIcon.Information,
MessageBoxDefaultButton.Button1);
}
private void BTF(int index)
{
switch (ListSongs[index].NameOfSong)
{
case "Happy":
HidePictures();
PicHappy.Visible = true;
break;
case "All Of Me":
HidePictures();
PicAllOfMe.Visible = true;
break;
case "Dark Horse":
HidePictures();
PicDarkHorse.Visible = true;
break;
case "Talk Dirty":
HidePictures();
PicTalkDirty.Visible = true;
break;
case "Let It Go":
HidePictures();
PicLetItGo.Visible = true;
break;
case "Pompeii":
HidePictures();
PicPompeii.Visible = true;
break;
case "Team":
HidePictures();
PicTeam.Visible = true;
break;
case "Counting Stars":
HidePictures();
PicCountingStars.Visible = true;
break;
case "The Man":
HidePictures();
PicTheMan.Visible = true;
break;
case "Turn Down For What":
HidePictures();
PicTurnDownForWhat.Visible = true;
break;
}
}
private void LbSongs_SelectedIndexChanged(object sender, EventArgs e)
{
IntSelInd = LbSongs.SelectedIndex;
LblThisWeek.Text = ListSongs[IntSelInd].LastWeekRank;
LblMostWeek.Text = ListSongs[IntSelInd].MostWeekRank;
LblLastWeek.Text = ListSongs[IntSelInd].LastWeekRank;
LblArtist.Text = ListSongs[IntSelInd].NameOfArtist;
BTF(IntSelInd);
axWindowsMediaPlayer1.URL = @ListSongs[IntSelInd].NameOfFile;
}
Timer (Add [timer1.Start();] In Frm Load)
DateTime datetime = DateTime.Now;
this.LblTime.Text = datetime.ToString();