![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Programmer
Join Date: Sep 2007
Posts: 33
Rep Power: 0
![]() |
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.... |
|
|
|
|
|
#2 |
|
Programming Guru
![]() ![]() ![]() |
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." |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Sep 2007
Posts: 33
Rep Power: 0
![]() |
Re: Arraylist ideas
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.... |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Sep 2007
Posts: 33
Rep Power: 0
![]() |
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.... |
|
|
|
|
|
#5 |
|
Programming Guru
![]() ![]() ![]() |
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." |
|
|
|
|
|
#6 |
|
Programmer
Join Date: Sep 2007
Posts: 33
Rep Power: 0
![]() |
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.... |
|
|
|
|
|
#7 |
|
Programmer
Join Date: Nov 2007
Posts: 86
Rep Power: 2
![]() |
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.
|
|
|
|
|
|
#8 |
|
Programming Guru
![]() ![]() ![]() |
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." |
|
|
|
|
|
#9 | |
|
Programmer
Join Date: Sep 2007
Posts: 33
Rep Power: 0
![]() |
Re: Arraylist ideas
Quote:
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.... |
|
|
|
|
|
|
#10 |
|
Programming Guru
![]() ![]() ![]() |
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." |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
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 |