Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 28th, 2007, 9:36 AM   #1
Sil3ncer7
Programmer
 
Join Date: Sep 2007
Posts: 33
Rep Power: 0 Sil3ncer7 is on a distinguished road
Post Arraylist ideas

I am trying to pull a value(9 digit number) from a text box then run it through an array and each run... Then list the array in a list box..

using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

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

        private void cmdProcess_Click(object sender, EventArgs e)
        {
           for (long i = txtstart; i <= txtend; i++)
           lstList.Item.Add(i)
        }
    }
}


But its not running through. It keeps inserting "0" in the lstbox

Any ideas?
__________________
Slowly but surly trying to learn C#, SQL, VB.Net, and wondering if a tornado crosses the equator if it spins backwards....
Sil3ncer7 is offline   Reply With Quote
Old Nov 28th, 2007, 10:04 AM   #2
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,473
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
Re: Arraylist ideas

How are you defining txtstart and txtend?

"EventArgs e" should be "System.EventArgs e"

"lstList.Item.Add()" should be "lstList.Items.Add()"

Not sure exactly what you are looking for, but maybe this will help. I suppose it depends on what you expect to be in your array.
This code takes a nine digit number, pushes it to a string to reference its elements, then reads each element into the listbox.


        private void cmdProcess_Click(object sender, System.EventArgs e)
        {
            long num = 123456789;
            string n = num.ToString();

            for (int i = 0; i < 9; i++)
                lstList.Items.Add(n[i]);
        }
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Nov 28th, 2007, 10:10 AM   #3
Sil3ncer7
Programmer
 
Join Date: Sep 2007
Posts: 33
Rep Power: 0 Sil3ncer7 is on a distinguished road
Re: Arraylist ideas

Quote:
Originally Posted by Infinite Recursion View Post
How are you defining txtstart and txtend?
What do you mean? i guess they would be int cause theyd be a 9 digit number????
__________________
Slowly but surly trying to learn C#, SQL, VB.Net, and wondering if a tornado crosses the equator if it spins backwards....
Sil3ncer7 is offline   Reply With Quote
Old Nov 28th, 2007, 10:16 AM   #4
Sil3ncer7
Programmer
 
Join Date: Sep 2007
Posts: 33
Rep Power: 0 Sil3ncer7 is on a distinguished road
Re: Arraylist ideas

So, if I were to have a txtbox to enter in that 9 digit number you would just use
long num = val txtStart??
__________________
Slowly but surly trying to learn C#, SQL, VB.Net, and wondering if a tornado crosses the equator if it spins backwards....
Sil3ncer7 is offline   Reply With Quote
Old Nov 28th, 2007, 10:49 AM   #5
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,473
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
Re: Arraylist ideas

What are the values of txtstart and txtend when you are entering the for loop? I didn't see where they were defined in code. If they were just referencing the start and end of the nine digit number then use 0 for the start and 8 for the end of your loop like I did. Or was it a range from one nine digit number to another nine digit number?

long num = Convert.ToInt32(txtStart.Text);
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Nov 28th, 2007, 10:53 AM   #6
Sil3ncer7
Programmer
 
Join Date: Sep 2007
Posts: 33
Rep Power: 0 Sil3ncer7 is on a distinguished road
Re: Arraylist ideas

Here is what I am working on.. if this is a little more understanding


you put in say 3216510001

and you supply the end at say 3216510005

so itll display in the lstList

3216510001
3216510002
3216510003
3216510004
3216510005

etc
__________________
Slowly but surly trying to learn C#, SQL, VB.Net, and wondering if a tornado crosses the equator if it spins backwards....
Sil3ncer7 is offline   Reply With Quote
Old Nov 28th, 2007, 11:24 AM   #7
mbd
Programmer
 
Join Date: Nov 2007
Posts: 86
Rep Power: 2 mbd is on a distinguished road
Re: Arraylist ideas

txtStart.Text would be a string representation of the text the user entered in that box. int.Parse(txtStart.Text) would return an integer representation of that text if it was formatted properly. If it was not formatted properly, it would throw a FormatException.
mbd is offline   Reply With Quote
Old Nov 28th, 2007, 2:29 PM   #8
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,473
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
Re: Arraylist ideas

Try this...

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

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

        private void cmdProcess_Click_1(object sender, System.EventArgs e)
        {
            long start = Convert.ToInt64(txtStart.Text);
            long stop = Convert.ToInt64(txtEnd.Text);

            for (long i = start; i <= stop; i++)
                lstList.Items.Add(i.ToString());
        }
    }
}
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Nov 28th, 2007, 3:08 PM   #9
Sil3ncer7
Programmer
 
Join Date: Sep 2007
Posts: 33
Rep Power: 0 Sil3ncer7 is on a distinguished road
Re: Arraylist ideas

Quote:
Originally Posted by Infinite Recursion View Post
Try this...

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

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

        private void cmdProcess_Click_1(object sender, System.EventArgs e)
        {
            long start = Convert.ToInt64(txtStart.Text);
            long stop = Convert.ToInt64(txtEnd.Text);

            for (long i = start; i <= stop; i++)
                lstList.Items.Add(i.ToString());
        }
    }
}

Sweet thanks. I started getting the out of range handler so I was gonna switch it from the int 32 to int64.. Thanks for the help.
__________________
Slowly but surly trying to learn C#, SQL, VB.Net, and wondering if a tornado crosses the equator if it spins backwards....
Sil3ncer7 is offline   Reply With Quote
Old Nov 28th, 2007, 3:17 PM   #10
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,473
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
Re: Arraylist ideas

Yeah... my fault for mentioning the int32 without testing it. I caught that problem and switched to int64.
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ArrayList Start Index kruptof C# 8 Sep 2nd, 2007 11:20 AM
Problem with an ArrayList Twilight C# 2 Apr 25th, 2006 2:15 PM
ArrayList and MSDN Writlaus C++ 13 Apr 5th, 2006 4:27 AM
ArrayList Troubles crawforddavid2006 Java 17 Jan 10th, 2006 7:37 PM
Converting object to arraylist yusufozkay C# 1 Jul 18th, 2005 9:08 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:26 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC