Robotic Process Automation
Robotic Process Automation
10
Aim: To design a form to perform using date, time and string functions.
Practical Course Outcome: To design a form to perform using date, time and string
functions.
Theory:
Visual Studio empowers you to complete the entire development cycle in one place. For
example, you can edit, debug, test, version control, and deploy to the cloud. With the
diversity of features and languages in Visual Studio, you can grow from writing your first
piece of code to developing in multiple project types.
Procedure:
To design a form that uses date, time, and string functions in .NET using Visual Studio, you
can follow these steps:
1. Open Visual Studio and create a new Windows Forms Application project.
2. Drag and drop the necessary controls onto the form, such as TextBoxes, Labels, and
Buttons.
3. Add the necessary namespaces at the top of the code file, such as
System.Globalization for formatting dates and times.
4. In the Button_Click event handler, write the code to perform the desired operations
using date, time, and string functions.
5. Use DateTime.Parse or DateTime.TryParse to convert a string to a DateTime object.
6. Use DateTime.Now to get the current date and time.
7. Use DateTime.ToString or String.Format to format a date or time string.
8. Use String.Concat or String.Join to concatenate strings.
9. Use String.IndexOf or String.Contains to search for a substring within a string.
10. Use String.Replace to replace a substring with another string.
Code:
a.
namespace rpa10
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(dateTimePicker1.Value.Hour.ToString());
}
private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show(dateTimePicker1.Value.Year.ToString());
}
private void button3_Click(object sender, EventArgs e)
{
MessageBox.Show(dateTimePicker1.Value.Month.ToString());
}
private void button4_Click(object sender, EventArgs e)
{
MessageBox.Show(dateTimePicker1.Value.Day.ToString());
}
}
}
b.
namespace exp10string
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button8_Click(object sender, EventArgs e)
{
textBox2.Text = textBox1.Text.Trim();
}
private void button1_Click(object sender, EventArgs e)
{
textBox2.Text = textBox1.Text.Clone().ToString();
}
private void button2_Click(object sender, EventArgs e)
{
int i;
i = textBox2.Text.CompareTo(textBox1.Text);
MessageBox.Show(i.ToString());
}
private void button3_Click(object sender, EventArgs e)
{
Boolean j;
j = textBox1.Text.Contains(textBox2.Text);
MessageBox.Show(j.ToString());
}
private void button6_Click(object sender, EventArgs e)
{
textBox1.Text = textBox2.Text.ToUpper();
}
private void button5_Click(object sender, EventArgs e)
{
textBox1.Text = textBox2.Text.ToLower();
}
private void button4_Click(object sender, EventArgs e)
{
Boolean k;
k = textBox1.Text.Equals(textBox2.Text);
MessageBox.Show(k.ToString());
}
private void button12_Click(object sender, EventArgs e)
{
int l;
l = textBox1.Text.Length;
MessageBox.Show(l.ToString());
}
private void button9_Click(object sender, EventArgs e)
{
textBox2.Text = textBox1.Text.Replace(textBox1.Text, textBox2.Text);
}
private void button10_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text.Remove(textBox1.Text.Length - 1);
}
private void button11_Click(object sender, EventArgs e)
{
textBox2.Text = textBox1.Text.Substring(textBox1.Text.Length -11);
}
}
}
Resources Required:
● Internet
● Desktop/Laptop
● Chrome/Internet explorer
● Notepad
● Microsoft Visual Studio
Output:
a.
b.
Conclusion:
From this experiment how to create a page in visual studio. And a learned the code used for
the coding of that. Also learnt how to get the date, time and used different string operators in
it.