473,671 Members | 2,588 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to iterate and display an Int Array list in a textBox? this has to be easy...

13 New Member
Ok guys,

I feel foolish here, but I have made a couple random hands of cards and wanted to see the full contents of those cards in a couple of textboxes.

But I suddenly realized that I am not sure how to do this?

If I loop through the twenty cards it will only show me the last one.

I need to concatenante it in an easy fashion. I KNOW that I could go simply do this:

string shuffledCards = myCards.arrayli st[1].ToString() + myCards.arrayli st[2].ToString() and on and on and on... and then place that string in a textBox....

BUT that cannot be the only way or even a good way to do it -- especially since I have 20 cards in each deck....can someone help me here?
Jun 27 '07 #1
2 1560
nateraaaa
663 Recognized Expert Contributor
Ok guys,

I feel foolish here, but I have made a couple random hands of cards and wanted to see the full contents of those cards in a couple of textboxes.

But I suddenly realized that I am not sure how to do this?

If I loop through the twenty cards it will only show me the last one.

I need to concatenante it in an easy fashion. I KNOW that I could go simply do this:

string shuffledCards = myCards.arrayli st[1].ToString() + myCards.arrayli st[2].ToString() and on and on and on... and then place that string in a textBox....

BUT that cannot be the only way or even a good way to do it -- especially since I have 20 cards in each deck....can someone help me here?
Have you considered using a loop to concatenate the array text into a string?

Expand|Select|Wrap|Line Numbers
  1. string shuffledCards = "";
  2. for(int i = 0; i < arraylist.Length; i++)
  3. {
  4. shuffledCards += shuffledCards + myCards.arraylist[i].ToString();
  5. }
  6. txtHands.Text = shuffledCards;
You may need to add spacing between each listed card in your textbox. I am not sure how you are wanting to display these to the user.

Nathan
Jun 27 '07 #2
tvance929
13 New Member
Awesome!

That almost worked perfectly!

I did have to change it a little (maybe this is just a c# thing) --- but I had to removed the shuffledCards out of your statement, because it added the same numbers over and over again.
you had :
shuffledCards += shuffledCards + fullDeck[i].ToString() + "\r\n";

had to make it:
shuffledCards += " " + fullDeck[i].ToString() + "\r\n";

BUT still, you really helped me and thanks a ton!
Jun 28 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1443
by: rbutch | last post by:
hey guys got a question. im trying to bind a textbox "at runtime". im creating the conn string, dataset, dataAdapter etc dynamically. and it keeps erroring out. <asp:TextBox ID="txtDay1" Runat="server" TextMode='<%# A39.DataRow%>'></asp:TextBox> now i have no problem doing this if i hard code my connection string, dataadapter, dataset etc and use the method (databinder eval). <asp:TextBox ID="txtDay1" Runat="server"
7
5045
by: Rich | last post by:
Hello, I have a form with 5 textboxes named txt0, txt1, txt2, txt3, tx4. In VB6 I could iterate through these with For i = 0 to 4 debug.print Me.controls("txt" & i).Name Next
3
25822
by: John | last post by:
i have lists with 10 and more textboxes for example test1.text, test2.text ....i want as i could do in vb6 with just a copy-paste of the same textbox, to have an array like test(1).text, test(2).text and to change the contents with a loop like "for"...is there any simple way to solve it? thank you in advance
10
3000
by: javuchi | last post by:
I just want to share some code with you, and have some comments and improvements if you want. This header file allocates and add and delete items of any kind of data from a very fast array: #include <stdlib.h> #ifndef __LIST_H__ #define __LIST_H__
0
2502
by: chongming | last post by:
Hi, i want to display all the filenames on browser. However i found that if there are many filenames in that folder, result will be it will display a long list of filenames on that browser. My question is how do i iterate the file names with 5 filenames on each page? I have manage to retrieve and display the filenames with the codes below. Can anyone help me or give advice on how to do the iteration? The codes are below and able to...
25
25437
RMWChaos
by: RMWChaos | last post by:
Any JSON experts out there? I'd like to know if it is possible, and if so how, to iterate through a JSON property list so that each iteration selects the next value for each object. Here is an example list: function myFunction() { createDOM({ 'id' : , 'dom' : , 'parent' : "content", 'form' : ,
15
7720
RMWChaos
by: RMWChaos | last post by:
As usual, an overly-long, overly-explanatory post. Better too much info than too little, right? A couple weeks ago, I asked for some assistance iterating through a JSON property list so that my code would either select the next value in the member list or the single value. The original post can be found here. This is the code gits helped me write: for (var i = 0; i < attribList.id.length; i++) { var attrib = {};
4
8870
by: im12345 | last post by:
I have the following question: Im doing a sample application using dojo and json. I have 2 classes: 1. Book class package com.esolaria.dojoex; import org.json.JSONObject; import org.json.JSONException;
3
2093
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I have a webform with several entry boxes and the user enters numbers in each box. I keep a running total (just adds all of the entries together) but am posting back to the server to do this. Is there any way to do it all on the client side, without posting back to the server? I would like to update the running total each time the user inputs an amount in a textbox and then goes to the next textbox. Thanks, -- Paul G Software...
0
8403
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8828
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8677
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7446
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6238
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5704
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4417
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2819
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.