Question

c#,

i have multiple arrays, When i click the submit button i want all the data in the textboxes and the date to store in those arrays respectively.
after that it prompts the user a yes or no dialog where if yes is clicked the user enters more data and gets stored in the arrays(and loops if yes is chosen again.)
when no is clicked the form closes.

how do i do this?

public static String[] city; public static DateTime[] date; public static intlI iil public static int[] maxTemp; public statiForm2 Capture weather data City Date Min Tempreture Max Temperture: Precipitation: Humidity: Wind Speed: 06 April 2019 km/h C

For example this is the first entry:

It stores this data into arrays for each:

Then i want to add another entry:

園Form2 Capture weather data City Date Min Tempreture: Max Temperture: 11 Precipitation: Humidity: Wind Speed: Rouen 07 April

And stores this into the arrays.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Output will be like:

Form1 Capture Weather Data city Sunday Apn 7. 2019 Min temerature Max temperature Precipitation Humidity Wind speed Cancel Su

Code will be like:

using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace CaptureWeatherDataForm
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

public static string[] city=new string[10];
public static DateTime[] date=new DateTime[10];
public static string[] minTemp = new string[10];
public static string[] maxTemp = new string[10];
public static string[] precipitation = new string[10];
public static string[] humidity = new string[10];
public static string[] windSpeed = new string[10];
int count = 0;
bool condition = false;
private void button2_Click(object sender, EventArgs e)
{

do
{

city[count] = textBox1.Text;
date[count] = dateTimePicker1.Value;
minTemp[count] = textBox2.Text;
maxTemp[count] = textBox3.Text;
precipitation[count] = textBox4.Text;
humidity[count] = textBox5.Text;
windSpeed[count] = textBox6.Text;
count++;

string message = "Do you want to enter more?";
string title = "Message window";
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
DialogResult result = MessageBox.Show(message, title, buttons);
if (result == DialogResult.Yes)
{
condition = true;

textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
textBox5.Text = "";
textBox6.Text = "";
  

}
else
{
condition = false;
}
}
while (condition == true);
}

private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
}
}

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.

Add a comment
Know the answer?
Add Answer to:
c#, i have multiple arrays, When i click the submit button i want all the data...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a program, Weather.java, which loads an unsorted set of weather data for Pendleton, sorts the...

    Create a program, Weather.java, which loads an unsorted set of weather data for Pendleton, sorts the data by date (handling date errors), and performs some analysis of the data (e.g. min/max temperature), and outputs the sorted data set to a file. Sample data: 2015-12-12,47,43,38,32,12,39,0.09,7,Rain,205 2015-05-08,73,56,38,18,7,22,0,0,,75 2015-11-10,51,44,37,18,8,21,0,4,,261 2016-02-02,45,36,26,12,5,14,0,1,,111 2015-06-28,109,89,68,38,11,48,T,0,Rain-Thunderstorm,296 Write methods to calculate each of the following on the given data set: Max. temperature Min. temperature Max. wind gust Max. precipitation and what the 'events' were for that day Each result...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT