Click here to Skip to main content
12,253,908 members (66,354 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#
hi my friends:
i want to take 10 numbers from user that show me the smallest and biggest number and i want to do it with array. in windows application. please help me.
thanks
Posted 2-Oct-12 10:02am
Comments
   
Help with what? This is not a question; and it's not clear what you want and where did you stuck. What smallest and biggest numbers, for goodness sake?
--SA
fatima...68 2-Oct-12 17:04pm
   
smallest and biggest number through inputting numbers
Ravi Bhavnani 2-Oct-12 16:10pm
   
This smells like homework. What have you tried doing?
fatima...68 2-Oct-12 17:01pm
   
it is a very simple example but i dont know that how i can put numbers from text box in array
JOHN 602 2-Oct-12 16:39pm
   
It looks like that if smb don't want do smth by him/herself and first of all go and post it on the site. Maybe there is a simpleton who will scribble the answer.
Your question it is just a nonsense.You may found how to operate with the arrays, I bet, on the first 50 pages of any book related to C#
fatima...68 2-Oct-12 16:59pm
   
thanks for your comment
gladiatron 2-Oct-12 17:12pm
   
@JOHN 602: mate, there is no need to be rude on these forums, neither is it welcome. You are not required to answer or comment or reply if you don't like the question.
Al Hizbul 2-Oct-12 16:40pm
   
Hey do u want to take 10 number from 10 individual textbox or from one textbox?
fatima...68 2-Oct-12 16:54pm
   
from one text box dear friend
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

OK, i'll help you, but algorithm to display the biggest and smallest values, you must to write by yourself.
Steps to do:
1) Create new windows application project
2) On the form place:
- 1x TextBox
- 3x Buttons (change the names as follow: BtnAdd, BtnClear, BtnDisplayResults)
- 1x ListBox
3) copy and paste the code below:
Public Class Form1
 
    Dim numbers As List(Of Integer) = Nothing 'declare list of integer

    Public Sub New()
 
        ' This call is required by the Windows Form Designer.
        InitializeComponent()
        numbers = New List(Of Integer) 'initialize variable
        ' Add any initialization after the InitializeComponent() call.

    End Sub
 
    Protected Overrides Sub Finalize()
        numbers = Nothing
        MyBase.Finalize()
    End Sub
 
    Private Sub BtnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnAdd.Click
        Dim sText As String = String.Empty
        sText = Me.TextBox1.Text 'get text from TextBox
        numbers.Add(Integer.TryParse(sText, 0)) 'try to add parsed value
        Me.TextBox1.Text = String.Empty 'clear TextBox
        Me.TextBox1.Focus() 
        Me.ListBox1.Items.Add(sText)
    End Sub
 
    Private Sub BtnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnClear.Click
        Me.ListBox1.Items.Clear()
        numbers.Clear()
    End Sub
 
    Private Sub BtnDisplayResults_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnDisplayResults.Click
        'here you need to write custom algorithm

    End Sub
 
End Class
4) Compile project

I use: ListOf(T)[^] to store numbers.
  Permalink  
Comments
Marcus Kramer 3-Oct-12 12:42pm
   
My vote of 2. Doing someone's homework will certainly NOT help them learn. By all means given them concepts and such, but giving them copy/paste capable code is useless for them.
Maciej Los 3-Oct-12 16:50pm
   
Marcus, have i done OP's homework? Not! Please have a look at the code. The main part of code - algorithm to show/display min and max values - is not implemented. So, OP need to study the code to understand it's meaning.
I can accept your vote, but i can't agree with your comment.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

The codes that you need are below (You should write your values inside a textbox inserting spaces between them):
string[] strArray = TextBox1.Text.Split(' ');
 
int biggest = Int32.MinValue;
int smallest = Int32.MaxValue;
 
for (int i = 0; i < strArray.Length; i++)
{
    int intVal = Int32.Parse(strArray[i].Trim());
 
    if (intVal > biggest)
        biggest = intVal;
 
    if (intVal < smallest)
        smallest = intVal;
}
 
MessageBox.Show("The biggest: " + biggest.ToString() +
                ", The smallest: " + smallest.ToString());
  Permalink  
Comments
Marcus Kramer 3-Oct-12 12:42pm
   
My vote of 2. Doing someone's homework will certainly NOT help them learn. By all means given them concepts and such, but giving them copy/paste capable code is useless for them.
Huseyin Atasoy 3-Oct-12 12:51pm
   
I am just trying to give the answer. I don't have to think if she will learn, this is her problem! If she want, she can learn many things from an example. We are not her teachers.
There was a question and this is the answer.
Please don't downvote the answers again for your personal obsessions!
Marcus Kramer 3-Oct-12 12:55pm
   
That is where you are wrong. If we are providing solutions here on CP, we ARE teachers and should take that approach. Most CP members do not condone cut/paste solutions for clear homework questions because we do not want to work with people who will graduate without knowing anything. Don't flatter yourself with the "personal obsession" statement. When I downvote I do it on principle based on community values. It isn't personal.
Huseyin Atasoy 3-Oct-12 13:42pm
   
I think some experienced users are always disinclining new users on CP.
I have encountered with such users when I was writing articles. Then I have decided not to write any article again.
And now, I decided not post any answer as well. (I know, you don't care about that.)
You can warn without downvoting. If you had warned me, maybe you would see something like "Thanks, you are right."
Additionally your profile is full of "My vote of 1". Don't you think that you are discouraging new users?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160426.1 | Last Updated 3 Oct 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100