Hi there. Really need help with this Visual Studios C # problem. I was asked to create a GUI application whose button's Click() method accepts ten integer values from a TextBox and stores them in an array that is declared above the Click() method. After the ten entries have been made, call a method that sorts and displays the ten values from smallest to largest.
Precise what your question is, so we can help you..
We would need to see your code to have any clue what the problem might be.
I've done the following code, but when I hit submit it does not sort the integers... using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace SmallAndLargeGUI { public partial class SmallAndLargeGUI : Form { public SmallAndLargeGUI() { InitializeComponent(); } int[] numberArr = new int[10]; int numbersEnteredCount = 0; private void btnSubmit_Click(object sender, EventArgs e) { numberArr[numbersEnteredCount] = Int32.Parse(txtNumber.Text); //Increment numbers entered numbersEnteredCount++; //Clear number for next entry txtNumber.Text = ""; txtNumber.Focus(); //All 10 numbers entered if (numbersEnteredCount == 10) { processArray(); btnSubmit.Enabled = false; txtNumber.Enabled = false; } } private void processArray() { //Set the smallest/largest to the first element of array int smallest = numberArr[0]; int largest = numberArr[0]; for (int i = 0; i < numberArr.Length; i++) { if (numberArr[i] < smallest) { smallest = numberArr[i]; } if (numberArr[i] > largest) { largest = numberArr[i]; } } txtSmallest.Text = smallest.ToString(); txtLargest.Text = largest.ToString(); } private void textBox6_TextChanged(object sender, EventArgs e) { } } }
A good habit is to use pastebin.com when attempting to display any form of code~
Or one of the others, or user the code block feature here. In this: ``` numberArr[numbersEnteredCount] = Int32.Parse(txtNumber.Text); ``` Is txtNumber.Text going to be just one number or all numbers at once?
@Double_A This is one c# student. Let me see if I find the other. You all might be able to learn together.
Join our real-time social learning platform and learn together with your friends!