Hey there, I am having a hard time using GUI for c# in visual studio. I am making an alarm clock. I have a few questions that I would like to know how to do:
--using a button called set time to capture text from a box containing a user-inputted hour, minute, second, and setting the current time to that.
--using a button called alarm, Capture the Text in the TextBoxes - the Hours, Minutes, Seconds and Text (am/pm) and create a new AlarmTime object with those for values for Hours, Minutes, Seconds and Message (am / pm) and enter the time of the alarm in the ListBox (the ListBox should always be sorted).
Output will be like


Note: The alarm time listed is auto sorted using the hour alone
Code will be like
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace AlaramTimeForms
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
List<Alaram> list = new List<Alaram>();
private void button1_Click(object sender, EventArgs e)
{
currentTime obj = new currentTime();
obj.hour = textBox1.Text;
obj.minute = textBox2.Text;
obj.second = textBox3.Text;
}
private void button3_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
Alaram obj = new Alaram();
obj.hour = Convert.ToInt16(textBox6.Text);
obj.minute = textBox5.Text;
obj.second = textBox4.Text;
obj.text = textBox7.Text;
list.Add(obj);
List<Alaram> SortedList = list.OrderBy(o =>
o.hour).ToList();
for (int i = 0; i < list.Count; i++)
{
listBox1.Items.Add(SortedList[i].hour + "," + SortedList[i].minute
+ "," + SortedList[i].second + "," + SortedList[i].text);
}
}
}
class currentTime
{
public string hour;
public string minute;
public string second;
}
class Alaram
{
public int hour;
public string minute;
public string second;
public string text;
}
}
Designer code will be like:
namespace AlaramTimeForms
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should
be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.textBox3 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.label4 = new System.Windows.Forms.Label();
this.textBox4 = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.textBox5 = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.textBox6 = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.textBox7 = new System.Windows.Forms.TextBox();
this.button3 = new System.Windows.Forms.Button();
this.listBox1 = new System.Windows.Forms.ListBox();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(58, 35);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 20);
this.textBox1.TabIndex = 0;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(13, 38);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(30, 13);
this.label1.TabIndex = 1;
this.label1.Text = "Hour";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(13, 85);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(39, 13);
this.label2.TabIndex = 3;
this.label2.Text = "Minute";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(58, 82);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(100, 20);
this.textBox2.TabIndex = 2;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(13, 128);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(44, 13);
this.label3.TabIndex = 5;
this.label3.Text = "Second";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(63, 125);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(100, 20);
this.textBox3.TabIndex = 4;
//
// button1
//
this.button1.Location = new System.Drawing.Point(42, 190);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 6;
this.button1.Text = "set time";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new
System.EventHandler(this.button1_Click);
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(271, 128);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(44, 13);
this.label4.TabIndex = 12;
this.label4.Text = "Second";
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(321, 125);
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(100, 20);
this.textBox4.TabIndex = 11;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(271, 85);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(39, 13);
this.label5.TabIndex = 10;
this.label5.Text = "Minute";
//
// textBox5
//
this.textBox5.Location = new System.Drawing.Point(316, 82);
this.textBox5.Name = "textBox5";
this.textBox5.Size = new System.Drawing.Size(100, 20);
this.textBox5.TabIndex = 9;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(271, 38);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(30, 13);
this.label6.TabIndex = 8;
this.label6.Text = "Hour";
//
// textBox6
//
this.textBox6.Location = new System.Drawing.Point(316, 35);
this.textBox6.Name = "textBox6";
this.textBox6.Size = new System.Drawing.Size(100, 20);
this.textBox6.TabIndex = 7;
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(246, 174);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(64, 13);
this.label7.TabIndex = 14;
this.label7.Text = "Text am/pm";
//
// textBox7
//
this.textBox7.Location = new System.Drawing.Point(321, 174);
this.textBox7.Name = "textBox7";
this.textBox7.Size = new System.Drawing.Size(100, 20);
this.textBox7.TabIndex = 13;
//
// button3
//
this.button3.Location = new System.Drawing.Point(321, 229);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(75, 23);
this.button3.TabIndex = 16;
this.button3.Text = "Alaram";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new
System.EventHandler(this.button3_Click);
//
// listBox1
//
this.listBox1.FormattingEnabled = true;
this.listBox1.Location = new System.Drawing.Point(181, 312);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(120, 95);
this.listBox1.TabIndex = 17;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(517, 449);
this.Controls.Add(this.listBox1);
this.Controls.Add(this.button3);
this.Controls.Add(this.label7);
this.Controls.Add(this.textBox7);
this.Controls.Add(this.label4);
this.Controls.Add(this.textBox4);
this.Controls.Add(this.label5);
this.Controls.Add(this.textBox5);
this.Controls.Add(this.label6);
this.Controls.Add(this.textBox6);
this.Controls.Add(this.button1);
this.Controls.Add(this.label3);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.label2);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox textBox4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox textBox5;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox textBox6;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.TextBox textBox7;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.ListBox listBox1;
}
}
Please rate it if the above solution helps you in any way or if you have any concerns comment it, I will help you through again.
Hey there, I am having a hard time using GUI for c# in visual studio. I...
This is a C++ Program I created in Visual Studio for class. The problem I am having is I get an error msg that says, "no matching token found for line 8." What am I missing? I see an opening bracket and a closing bracket. But, the program will not build because it says more or less the bracket is missing. FYI....Line 8, is the bracket directly under int main (). Can someone help me understand where I am going...
Can you write the code for this
It's for Visual Basic
I am having a hard time getting it to work
Telling me error
Thank u I will rate a good so other students can learn from
this
(Mobile-Android Studio) Hello. Thank you for coming to help me:) I am using the Andriod studio on mac. and using Java code to develop. and Please start with basic activity with constraints layout (not empty). (audio file is not given, let's say there any audio file). I just would like to see the codes how it works. Thank you very much. I would like to know how to write a program that includes two buttons called plays Play and Stop....
C++ using visual studio. I need to make a dice rolling mechanic. When the dice falls on 1 it will display L, 2 will display R, 3 will display C and the remaining numbers will display A dot I am suppossed to use the code shown here in order to make it #include <ctime> srand(time(NULL)); // Get a random number between 0 and 5 unsigned int randomRoll = rand() % 6;
Hello. I am using Visual Studio 2019 and am not sure why it is telling me I have 5 errors when I BUILD my code in C++. Can someone please take a look? #include using namespace std; int main() { int number_of_quarters, total_value_of_quarters; int number_of_dimes, total_value_of_dimes; int number_of_nickels, total_value_of_nickels; int number_of_pennies, total_value_of_pennies; int total_value_of_coins, total_dollars, total_cents; cout<<"Please enter the # of quarters: "<>number_of_quarters; cout<<"Please enter the # of dimes: "<>number_of_dimes; cout<<"Please enter the # of nickels: "<>number_of_nickels; cout<<"Please enter the...
I am having a hard time with my program to assignment 4.12. Here
are the instructions:
The Payroll Department keeps a list of employee information for
each pay period in a text file. The format of each line of the file
is the following: <last name> <hours worked> <hourly
wage>
Write a program that inputs a filename from the user and prints
to the terminal a report of the wages paid to the employees for the
given period.
The report...
Problem: I am trying to implement a binary search function in Visual Studio 2019 using C#. This is my first program in C# and I translated it from Java. In this program, I am to carry out the same 10,000,000 unsuccessful searches for eight different-sized arrays, namely arrays of sizes, 128, 512, 2048, 8192, 32768, 131072, 524288, and 2,097,152. I need to measure each of the three programs and the time it takes to do the 10,000,000 searches for each...
Using Visual Studio 2015, how would I code the following
Uodate button event handler in c#?
then displayed in the student list box. Create an interface as follows The initial form for the application should appear as follows Student Scores Students dd New. Lpdate Delete Ext To update, delete or add student information create the following form Enter Student Information Name Student ID MdtemRna Cancel Note: the Control Box property is set to false
Hey, i was just wondering how i would calculate over time pay in c++ visual studio 2017? what i have right now is either returning 0 for some reason or being skipped over? im also wondering about the federal tax as well because that also doesn't seem to work, any help is greatly appreciated! these are my variables char chChoice = ' '; int intempID = 0; int intHours = 0; int intOThours = 0; float flOTrate = 0; float...
After watching the lectures I am still having a hard time understanding these equations. 1. The half-life of tritium is 12.3 years. How long does it take for a 48.0g sample to be reduced to 2.0g? Answer using equation(s). (I know itll be around 50 years but unsure about the equation) 2. Write balanced equations for: bismuth-214 undergoes beta decay, plutonium-242 emits alpha radiation, selenium-81 undergoes beta decay, uranium-235 undergoes alpha decay, 11C emits a positron, O-15 undergoes electron capture...